Ext.define("Ext.Custom.CustomPaging", {
	extend: Ext.toolbar.Paging,
	alias: "widget.custompaging",
	getPagingItems: function() {
		var e = this,
			h = /^(SO.model.)(.*?)(Model)$/g,
			b = e.store.model,
			l = Ext.create(e.store.model),
			g = "",
			k = "somainwindow",
			a = "ReportCommonsController.generateReportWithoutLimits",
			j;
		while ((j = h.exec(l.modelName))) {
			g = j[2]
		}
		var d = function() {
				var p = e.up().up().query("grid")[0].columns,
					n = [],
					r = e.store.data.items[0];
				for (colIdx in p) {
					var o = p[colIdx];
					if (o.dataIndex != "" && o.dataIndex != null) {
						var m = {
							dataIndex: o.dataIndex,
							text: o.text,
							dataType: ""
						};
						for (idx in l.fields.items) {
							var q = l.fields.items[idx];
							if (q.name != o.dataIndex) {
								continue
							}
							if (q.type.type == "auto") {
								m.dataType = getDataType(r ? r.get(q.name) : "")
							} else {
								m.dataType = q.type.type
							}
							break
						}
						n.push(m)
					}
				}
				return n
			};
		var i = function() {
				var n = "";
				for (idx in e.up().dockedItems.items) {
					var m = e.up().dockedItems.items[idx];
					if (m.componentCls == "x-panel") {
						if (typeof m.title != "undefined") {
							n = m.title;
							break
						}
					}
				}
				if (n == "") {
					n = typeof e.up().up().up().title != "undefined" ? e.up().up().up().title : ""
				}
				return n
			};
		var f = function() {
				var m = Ext.create("SO.custom.ConfigureExportWindow", {
					modelToLoad: l,
					availFields: d(),
					gridTitle: i(),
					beanName: g,
					resourceID: a,
					store: e.store
				});
				m.show();
				m.items.items[0].getForm().isValid()
			};
		var c = function() {
				var m = {
					resourceID: a,
					type: this.text,
					beanName: g,
					title: i(),
					allFields: false,
					isPortrait: true,
					listResourceID: e.store.proxy.extraParams.resourceID,
					filterModel: e.store.proxy.extraParams.filterModel,
					limit: -1,
					fieldsToAdd: Ext.encode(d())
				};
				Object.getOwnPropertyNames(e.store.proxy.extraParams).forEach(function(o, n, p) {
					if (o != "resourceID" && o != "filterModel" && o != "offset") {
						m[o] = e.store.proxy.extraParams[o]
					}
				});
				getResourceFile(m, k, null)
			};
		return [{
			itemId: "first",
			xtype: "tbspacer",
			width: 1
		}, {
			itemId: "prev",
			tooltip: e.prevText,
			overflowText: e.prevText,
			iconCls: Ext.baseCSSPrefix + "tbar-page-prev",
			disabled: false,
			handler: e.movePrevious,
			scope: e
		}, "-", e.beforePageText, {
			xtype: "numberfield",
			itemId: "inputItem",
			name: "inputItem",
			cls: Ext.baseCSSPrefix + "tbar-page-number",
			editable: false,
			hideTrigger: true,
			enableKeyEvents: true,
			keyNavEnabled: false,
			selectOnFocus: true,
			submitValue: false,
			isFormField: false,
			width: e.inputItemWidth,
			margins: "-1 2 3 2"
		}, {
			xtype: "tbtext",
			itemId: "afterTextItem",
			text: Ext.String.format(e.afterPageText, 1)
		}, "-", {
			itemId: "next",
			tooltip: e.nextText,
			overflowText: e.nextText,
			iconCls: Ext.baseCSSPrefix + "tbar-page-next",
			disabled: false,
			handler: e.moveNext,
			scope: e
		}, {
			itemId: "last",
			xtype: "tbspacer",
			width: 1
		}, "-", {
			itemId: "refresh",
			tooltip: e.refreshText,
			overflowText: e.refreshText,
			iconCls: Ext.baseCSSPrefix + "tbar-loading",
			disabled: true,
			handler: e.doRefresh,
			scope: e
		}, "-", {
			xtype: "button",
			itemId: "export",
			text: "Export",
			icon: path + "resources/images/16X16/export/eexport.png",
			menu: Ext.create("Ext.menu.Menu", {
				width: 100,
				defaults: {
					handler: c
				},
				items: [{
					text: "CSV",
					icon: path + "resources/images/16X16/export/ecsv.png"
				}, {
					text: "HTML",
					icon: path + "resources/images/16X16/export/ehtml.png"
				}, {
					text: "PDF",
					icon: path + "resources/images/16X16/export/epdf.png"
				}, {
					text: "XLS",
					icon: path + "resources/images/16X16/export/exls.png"
				}, {
					text: "Custom",
					icon: path + "resources/images/16X16/export/ecustom.png",
					handler: f
				}]
			})
		}]
	}
});
Ext.define("Ext.Custom.Report", {
	extend: Ext.Component,
	alias: "widget.report",
	autoEl: {
		tag: "iframe",
		cls: "x-hidden"
	},
	reportLoading: false,
	load: function(b) {
		var c = this.getEl(),
			a = window.windowSOContext.ajaxURL;
		if (typeof b == "undefined") {
			b = {}
		}
		if (typeof b.params == "undefined") {
			b.params = {}
		}
		b.params.resourceID = "ResourceFileCommonsController.retrieveFile";
		a = a + (a.indexOf("?") > -1 ? "&" : "?") + Ext.urlEncode(b.params);
		c.dom.src = a;
		c.dom.onload = function() {
			if (c.dom.contentDocument.body.childNodes[0] && c.dom.contentDocument.body.childNodes[0].wholeText != "") {
				Ext.CustomMessageBox.msg(b.params.screen, bundle.getMsg("socontrol.message.information"), bundle.getMsg(c.dom.contentDocument.body.childNodes[0].wholeText))
			}
		}
	}
});
Ext.define("Ext.Custom.CustomTextField", {
	extend: Ext.form.field.Text,
	alias: "widget.customtextfield",
	listeners: {
		blur: function() {
			this.setValue(Ext.String.trim(this.getValue()))
		}
	}
});
Ext.define("Ext.Custom.CustomTriggerField", {
	extend: Ext.form.field.Trigger,
	alias: "widget.customtriggerfield",
	blur: function() {
		this.setValue(Ext.String.trim(this.getValue()))
	},
	onTriggerClick: function(b) {
		var a = this;
		if (!a.hideTrigger) {
			a.fireEvent("triggerclick", a, b)
		}
	}
});
Ext.define("Ext.data.proxy.ServerOverride", {
	override: "Ext.data.proxy.Server",
	processResponse: function(e, b, d, a, f, c) {
		b.serverResponse = a;
		this.callParent(arguments)
	}
});
Ext.define("SO.model.MappingInformationModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "id",
		type: "int"
	}, {
		name: "opMapKey",
		type: "int"
	}, {
		name: "mapOpSeq",
		type: "int"
	}, {
		name: "locProc",
		type: "string"
	}, {
		name: "locProcText",
		type: "string"
	}, {
		name: "mapTypeKey",
		type: "int"
	}, {
		name: "invalid",
		type: "boolean"
	}],
	idProperty: "id"
});
Ext.define("SO.model.Location", {
	extend: Ext.data.Model,
	fields: [{
		name: "locationKey"
	}, {
		name: "locationDesc"
	}, {
		name: "name"
	}, {
		name: "unitStatusKey"
	}, {
		name: "unitStatusDesc"
	}, {
		name: "serialQty"
	}, {
		name: "processName"
	}, {
		name: "line"
	}, {
		name: "sfdcKey",
		type: "int"
	}, {
		name: "sfdcId"
	}]
});
Ext.define("SO.model.OperationSequence", {
	extend: Ext.data.Model,
	fields: [{
		name: "opseq"
	}, {
		name: "description"
	}, {
		name: "department"
	}, {
		name: "opCode"
	}],
	toString: function() {
		return this.data.opseq + " - " + this.data.opCode + " - " + this.data.description + " - " + this.data.department
	},
	toStringShort: function() {
		return this.data.opseq + " - " + this.data.opCode + " - " + this.data.description
	},
	toStringForOpSeqGrid: function() {
		return this.data.description + "<br> <b>" + this.data.opseq + " - " + this.data.opCode + " - " + this.data.department + "</b>"
	},
	toStringForMapping: function() {
		return "<b>" + this.data.opseq + " - " + this.data.opCode + "</b> - " + this.data.description + " - " + this.data.department
	}
});
Ext.define("SO.model.ShopOrderInformationModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "shopOrderNumber"
	}, {
		name: "partId"
	}, {
		name: "partNumber"
	}, {
		name: "revision"
	}, {
		name: "boardsPerPanel"
	}, {
		name: "numberOfPanels"
	}, {
		name: "increasedQuantity"
	}, {
		name: "updated"
	}, {
		name: "genericOrder"
	}, {
		name: "projectCode"
	}, {
		name: "organizationCode"
	}, {
		name: "shopOrderStatus"
	}, {
		name: "userId"
	}, {
		name: "userDefined"
	}, {
		name: "statusDate"
	}, {
		name: "startingSerialNumber"
	}, {
		name: "endingSerialNumber"
	}, {
		name: "startDate"
	}, {
		name: "completionDate"
	}, {
		name: "oraclePartNumber"
	}, {
		name: "oracleStatus"
	}, {
		name: "changeDate"
	}, {
		name: "isOnHold"
	}, {
		name: "transferOnHold"
	}, {
		name: "canBeDeleted"
	}, {
		name: "canBeClosed"
	}, {
		name: "isOracle"
	}, {
		name: "canDeleteUnstartedUnits"
	}, {
		name: "isBatchRelease"
	}, {
		name: "soLinkage"
	}, {
		name: "mapType"
	}, {
		name: "isSoLinked"
	}, {
		name: "bompkID",
		type: "int",
		persist: false
	}],
	validations: [{
		type: "presence",
		field: "ShopOrderNumber"
	}],
	idProperty: "shopOrderKey",
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "ShopOrderController.getShopOrderView",
			salesOrderId: 0
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	},
	hasMany: [{
		model: "SO.model.OperationSequence",
		name: "operationSequences"
	}, {
		model: "SO.model.MappingInformationModel",
		name: "mappings"
	}, {
		model: "SO.model.Location",
		name: "locations"
	}]
});
Ext.define("SO.view.ShopOrderBrowser.PrintLabelsWindow", {
	extend: Ext.window.Window,
	alias: "widget.printlabelswindow",
	id: "printlabelswindow",
	width: 400,
	height: 320,
	resizable: false,
	model: true,
	constrain: true,
	renderTo: "xmain",
	buildButtons: function() {
		var a = [{
			text: bundle.getMsg("socontrol.print"),
			action: "onPrint"
		}, {
			text: bundle.getMsg("socontrol.cancel"),
			handler: function() {
				this.up("window").close()
			}
		}];
		return a
	},
	initComponent: function() {
		var a = this;
		a.items = a.buildPanel();
		a.buttons = a.buildButtons();
		a.title = bundle.getMsg("socontrol.release.print.printLabelDialogTitle");
		a.border = 0;
		a.modal = true;
		a.layout = {
			type: "hbox",
			align: "center"
		};
		this.callParent(arguments)
	},
	doAjaxQueue: function() {
		scope = this;
		var a = this;
		Ext.Ajax.request({
			url: window.windowSOContext.ajaxURL,
			format: "json",
			params: {
				resourceID: "LabelController.getLabelComboboxStore",
				shopOrderId: a.shopOrderId,
				partKey: a.partKey,
				labelParam: Ext.getCmp("labelType").getValue(),
				combobox: "PrintType",
				partNumber: a.partNumber,
				labelEngineContext: label_engine_context,
				labelEngineToken: label_engine_token_jmds,
				printMode: "MDS"
			},
			success: function(b) {
				var c = Ext.getCmp("printerQueue").getStore();
				var e = Ext.decode(b.responseText);
				var d = Ext.create("Ext.data.Store", {
					fields: ["value"],
					autoLoad: false
				});
				d.loadData(e.data);
				c.removeAll();
				d.each(function(f) {
					c.add(f)
				})
			}
		})
	},
	buildPanel: function() {
		var a = Ext.create("Ext.form.Panel", {
			id: "printlabelsform",
			baseCls: "toolbarColor",
			width: 400,
			height: 270,
			padding: "15 15 15 15",
			items: [{
				xtype: "combobox",
				fieldLabel: bundle.getMsg("socontrol.release.print.printMode"),
				name: "printMode",
				id: "printMode",
				allowBlank: false,
				valueField: "value",
				displayField: "value",
				editable: true,
				forceSelection: true,
				queryMode: "local",
				store: Ext.create("Ext.data.Store", {
					fields: ["value"],
					autoLoad: true,
					proxy: {
						type: "ajax",
						format: "json",
						url: window.windowSOContext.ajaxURL,
						extraParams: {
							resourceID: "LabelController.getPrintModeStore"
						},
						reader: Ext.create("Ext.data.JsonReader", {
							successProperty: "success",
							messageProperty: "message",
							totalProperty: "totalCount",
							root: "data"
						})
					},
					listeners: {
						load: function() {
							var b = Ext.ComponentQuery.query("#printMode");
							var c = b[0].getStore().getAt(0);
							b[0].setValue(c.get("value"));
							b[0].fireEvent("select", b[0], c, 0)
						}
					}
				}),
				listeners: {
					select: function(i, b, e) {
						if (b[0] != null) {
							b = b[0]
						}
						var c = Ext.ComponentQuery.query("#labelType");
						var g = Ext.ComponentQuery.query("#printerQueue");
						var h = Ext.ComponentQuery.query("#initPrinter");
						var f = Ext.ComponentQuery.query("#createLabelPart");
						var d = Ext.ComponentQuery.query("#downloadLabelCheckBox");
						if (b.get("value").toUpperCase() == "MDS") {
							c[0].setFieldLabel(bundle.getMsg("socontrol.release.print.labelType"));
							c[0].clearValue();
							c[0].forceSelection = true;
							c[0].getStore().removeAll();
							c[0].getStore().getProxy().extraParams.combobox = "LabelType";
							c[0].getStore().getProxy().extraParams.printMode = "MDS";
							c[0].getStore().load({
								callback: function(k, j, l) {
									if (l == false) {
										failureHandler(j.serverResponse, "printlabelswindow")
									}
								}
							});
							g[0].clearValue();
							g[0].forceSelection = false;
							g[0].getStore().getProxy().extraParams.combobox = "PrintType";
							g[0].getStore().getProxy().extraParams.printMode = "MDS";
							h[0].setDisabled(false);
							f[0].setDisabled(false)
						} else {
							c[0].setFieldLabel(bundle.getMsg("socontrol.release.print.labelName"));
							c[0].clearValue();
							c[0].forceSelection = false;
							c[0].getStore().removeAll();
							c[0].getStore().getProxy().extraParams.combobox = "LabelName";
							c[0].getStore().getProxy().extraParams.printMode = "Label Engine";
							c[0].getStore().load({
								callback: function(k, j, l) {
									if (l == false) {
										failureHandler(j.serverResponse, "printlabelswindow")
									}
								}
							});
							g[0].clearValue();
							g[0].forceSelection = false;
							g[0].getStore().removeAll();
							g[0].getStore().getProxy().extraParams.combobox = "PrintName";
							g[0].getStore().getProxy().extraParams.printMode = "Label Engine";
							g[0].getStore().load({
								callback: function(k, j, l) {
									if (l == false) {
										failureHandler(j.serverResponse, "printlabelswindow")
									}
								}
							});
							h[0].setDisabled(true);
							f[0].setDisabled(true)
						}
						g[0].setDisabled(false);
						d[0].setValue(false);
						d[0].setVisible(false)
					}
				}
			}, {
				xtype: "combobox",
				fieldLabel: bundle.getMsg("socontrol.release.print.labelType"),
				name: "labelType",
				id: "labelType",
				valueField: "value",
				displayField: "value",
				maxLength: 30,
				enableKeyEvents: true,
				allowBlank: false,
				editable: true,
				forceSelection: false,
				queryMode: "local",
				store: Ext.create("Ext.data.Store", {
					fields: ["value", "a1"],
					autoLoad: false,
					proxy: {
						type: "ajax",
						format: "json",
						url: window.windowSOContext.ajaxURL,
						extraParams: {
							resourceID: "LabelController.getLabelComboboxStore",
							shopOrderId: this.shopOrderId,
							partKey: this.partKey,
							partNumber: this.partNumber,
							labelEngineContext: label_engine_context,
							labelEngineToken: label_engine_token_jmds
						},
						reader: Ext.create("Ext.data.JsonReader", {
							successProperty: "success",
							messageProperty: "message",
							totalProperty: "totalCount",
							root: "data"
						})
					}
				}),
				listeners: {
					blur: function(e, d, c) {
						var b = e.getValue() == null ? "" : e.getValue();
						e.setValue(Ext.String.trim(b))
					},
					keyup: {
						fn: function(d, c, b) {
							if (d.getValue() != null && d.getValue() != "" && d.getStore().getProxy().extraParams.combobox == "LabelType") {
								this.up("window").doAjaxQueue();
								this.enableDownloadLabel(d.findRecordByValue(d.getValue()))
							}
						},
						buffer: 1000
					},
					select: function(d, b, c) {
						if (b[0] != null) {
							b = b[0]
						}
						if (b.get("value") != null && b.get("value") != "" && d.getStore().getProxy().extraParams.combobox == "LabelType") {
							this.up("window").doAjaxQueue();
							this.enableDownloadLabel(b)
						}
					}
				},
				enableDownloadLabel: function(c) {
					var b = Ext.getCmp("downloadLabelCheckBox");
					if (Ext.isObject(c) && !Ext.isEmpty(c.get("a1")) && label_download_enable) {
						b.setVisible(true)
					} else {
						b.setVisible(false);
						b.setValue(false);
						Ext.getCmp("printerQueue").setDisabled(false)
					}
				}
			}, {
				xtype: "panel",
				border: 0,
				layout: {
					type: "column"
				},
				flex: 1,
				items: [{
					xtype: "combobox",
					fieldLabel: bundle.getMsg("socontrol.release.print.printer"),
					name: "printerQueue",
					id: "printerQueue",
					valueField: "value",
					displayField: "value",
					maxLength: 15,
					allowBlank: false,
					editable: true,
					queryMode: "local",
					store: Ext.create("Ext.data.Store", {
						fields: ["value"],
						autoLoad: false,
						proxy: {
							type: "ajax",
							format: "json",
							url: window.windowSOContext.ajaxURL,
							extraParams: {
								resourceID: "LabelController.getLabelComboboxStore",
								shopOrderId: this.shopOrderId,
								partKey: this.partKey,
								partNumber: this.partNumber,
								labelEngineContext: label_engine_context,
								labelEngineToken: label_engine_token_jmds
							},
							reader: Ext.create("Ext.data.JsonReader", {
								successProperty: "success",
								messageProperty: "message",
								totalProperty: "totalCount",
								root: "data"
							})
						}
					}),
					listeners: {
						blur: function(e, d, c) {
							var b = e.getValue() == null ? "" : e.getValue();
							e.setValue(Ext.String.trim(b))
						}
					}
				}, {
					xtype: "checkboxfield",
					boxLabel: bundle.getMsg("socontrol.release.print.localPrint"),
					id: "downloadLabelCheckBox",
					name: "downloadLabel",
					inputValue: "downloadLabel",
					hidden: true,
					listeners: {
						change: function(c, d, b) {
							Ext.getCmp("printerQueue").setDisabled(d)
						}
					},
					style: {
						marginLeft: "10px"
					}
				}]
			}, {
				xtype: "combobox",
				fieldLabel: bundle.getMsg("socontrol.release.print.initPrinter"),
				name: "initPrinter",
				id: "initPrinter",
				disabled: true,
				valueField: "value",
				displayField: "initPrinterDescription",
				editable: false,
				store: new Ext.data.ArrayStore({
					fields: ["value", "initPrinterDescription"],
					data: [
						[false, bundle.getMsg("label.no")],
						[true, bundle.getMsg("label.yes")]
					]
				}),
				listeners: {
					afterrender: function(b) {
						var c = b.getStore().getAt(0);
						b.setValue(c.get("initPrinterDescription"));
						b.fireEvent("select", b, c, 0)
					}
				}
			}, {
				xtype: "checkboxfield",
				boxLabel: bundle.getMsg("socontrol.list.confirmCreateLabelPart"),
				name: "createLabelPart",
				inputValue: "createLabelPart",
				id: "createLabelPart"
			}, {
				xtype: "fieldcontainer",
				fieldLabel: bundle.getMsg("socontrol.serialNumber"),
				defaultType: "radiofield",
				margin: "20 0 0 0",
				border: "1 0 0 0",
				style: {
					borderColor: "black",
					borderStyle: "solid"
				},
				layout: "vbox",
				items: [{
					boxLabel: bundle.getMsg("socontrol.release.print.allAvailableUnits"),
					name: "printtype",
					inputValue: "printallsns",
					id: "printallsns",
					checked: true,
					listeners: {
						change: function(f, e, b, c) {
							var d = Ext.ComponentQuery.query("#selectSnBtn");
							if (f.getValue()) {
								d[0].setDisabled(true)
							} else {
								d[0].setDisabled(false)
							}
						}
					}
				}, {
					boxLabel: bundle.getMsg("socontrol.release.print.selectSerialNumbers") + " (" + bundle.getMsg("socontrol.quantityTable") + ": 0)",
					name: "printtype",
					inputValue: "selectsns",
					id: "selectsns"
				}, {
					xtype: "button",
					text: bundle.getMsg("socontrol.select"),
					id: "selectSnBtn",
					action: "onSelectSnBtn",
					disabled: true
				}]
			}, {
				xtype: "hiddenfield",
				id: "serialNumberHiddenList",
				name: "serialNumberHiddenList"
			}]
		});
		return a
	}
});
Ext.define("Common.store.PaggingStore", {
	extend: Ext.data.Store,
	offsets: {},
	constructor: function(a) {
		a = a || {};
		this.callParent([a]);
		this.on({
			beforeload: this.onBeforeload
		})
	},
	onBeforeload: function(b, a, c) {
		if (a.page == 1) {
			this.offsets = {};
			this.offsets[1] = null
		}
		this.getProxy().extraParams.offset = Ext.encode(this.offsets[a.page])
	},
	onProxyLoad: function(b) {
		var d = this,
			c = b.getResultSet(),
			a = b.getRecords(),
			f = b.wasSuccessful();
		if (c) {
			d.totalCount = c.total
		}
		if (f) {
			d.loadRecords(a, b)
		}
		d.loading = false;
		d.fireEvent("load", d, a, f);
		d.fireEvent("read", d, a, b.wasSuccessful());
		Ext.callback(b.callback, b.scope || d, [a, b, f]);
		var e = Ext.decode(b.response.responseText);
		if (typeof(e.offset) != "undefined") {
			this.offsets[b.page + 1] = e.offset
		}
	}
});
Ext.define("SO.model.SerialNumberModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "serialNumber"
	}, {
		name: "id",
		defaultValue: 0
	}, {
		name: "containerKey",
		defaultValue: 0
	}, {
		name: "isContainer",
		defaultValue: false
	}, {
		name: "arrayContainerKey",
		defaultValue: []
	}, {
		name: "orderLineKey",
		defaultValue: 0
	}, {
		name: "shopOrderKey",
		defaultValue: 0
	}, {
		name: "unitStatusKey",
		defaultValue: 0
	}, {
		name: "unitStatus",
		defaultValue: 0
	}, {
		name: "location"
	}, {
		name: "quantity",
		defaultValue: 0
	}, {
		name: "unitType",
		defaultValue: 1
	}, {
		name: "revision"
	}, {
		name: "userDefined"
	}, {
		name: "dateTime"
	}, {
		name: "orderLine",
		defaultValue: 0
	}, {
		name: "shopOrderNumber"
	}],
	idProperty: "serialNumber"
});
Ext.define("SO.store.SerialNumberStore", {
	extend: Common.store.PaggingStore,
	model: "SO.model.SerialNumberModel",
	pageSize: 50,
	remoteSort: false,
	remoteFilter: false,
	autoLoad: false,
	constructor: function(a) {
		a = a || {};
		this.callParent([a]);
		this.setProxy({
			type: "ajax",
			format: "json",
			url: window.windowSOContext.ajaxURL,
			appendId: false,
			extraParams: {
				resourceID: "SerialNumberController...."
			},
			batchActions: true,
			reader: Ext.create("Ext.data.JsonReader", {
				successProperty: "success",
				messageProperty: "message",
				idProperty: "id",
				totalProperty: "totalCount",
				root: "data"
			}),
			writer: Ext.create("Ext.data.JsonWriter", {
				encode: false,
				writeAllFields: false,
				allowSingle: false
			})
		})
	}
});
Ext.define("SO.view.ShopOrderBrowser.ReleaseNotesHistoryWindow", {
	extend: Ext.window.Window,
	alias: "widget.releasenoteshistorywindow",
	id: "releasenoteshistorywindow",
	width: 500,
	height: 310,
	resizable: false,
	model: true,
	constrain: true,
	renderTo: "xmain",
	buildButtons: function() {
		var a = [{
			text: bundle.getMsg("socontrol.close"),
			handler: function() {
				this.up("window").close()
			}
		}];
		return a
	},
	initComponent: function() {
		var a = this;
		a.items = a.buildPanel();
		a.buttons = a.buildButtons();
		a.title = bundle.getMsg("socontrol.releaseNotesHistory");
		a.border = 0;
		a.modal = true;
		a.layout = {
			type: "hbox",
			align: "center"
		};
		this.callParent(arguments)
	},
	buildPanel: function() {
		var c = Ext.create("Ext.form.field.TextArea", {
			width: 488,
			height: 123,
			name: "notes",
			readOnly: true
		});
		var e = Ext.create("Ext.selection.RowModel", {
			listeners: {
				select: {
					fn: function(g, f, h) {
						c.setValue(f.data.notes)
					}
				}
			}
		});
		var d = Ext.create("Ext.grid.Panel", {
			width: 490,
			height: 105,
			autoScroll: true,
			id: "historygrid",
			selModel: e,
			columns: [{
				header: bundle.getMsg("socontrol.browser.createdBy"),
				flex: 1,
				dataIndex: "createUser",
				sortable: false
			}, {
				header: bundle.getMsg("socontrol.release.print.dateTime"),
				flex: 1,
				dataIndex: "createDttm",
				sortable: true
			}]
		});
		var a = Ext.create("Ext.panel.Panel", {
			width: 490,
			height: 151,
			items: c
		});
		var b = Ext.create("Ext.form.Panel", {
			width: 490,
			height: "100%",
			id: "releasehistoryinfo",
			baseCls: "toolbarColor",
			items: [d,
			{
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.releaseNotes")
			},
			a]
		});
		return b
	}
});
Ext.define("SO.model.ShopOrderModel", {
	extend: Ext.data.Model,
	require: ["Common.model.PartNumberModel"],
	fields: [{
		name: "id",
		type: "int"
	}, {
		name: "shopOrderNumber"
	}, {
		name: "partId",
		type: "int"
	}, {
		name: "quantity",
		type: "int"
	}, {
		name: "revision"
	}, {
		name: "opSeqListKey",
		type: "int"
	}, {
		name: "mapTypeKey",
		type: "int"
	}, {
		name: "shopOrderStatus"
	}, {
		name: "oracleShopOrderStatus",
		persist: false
	}, {
		name: "mappingId",
		type: "int",
		persist: false
	}, {
		name: "oracleShopOrder",
		persist: false
	}, {
		name: "bompkID",
		type: "int",
		persist: false
	}, {
		name: "userDefined"
	}, {
		name: "boardsPerPanel",
		type: "int",
		persist: false
	}, {
		name: "dueDate",
		useNull: false
	}, {
		name: "statusChangeDate",
		persist: false
	}, {
		name: "statusChangeTime",
		persist: false
	}, {
		name: "algorithmNumber",
		type: "int",
		persist: false
	}, {
		name: "algorithmName",
		persist: false
	}, {
		name: "serialNumberStatus",
		type: "int",
		persist: false
	}, {
		name: "startDate",
		persist: false
	}, {
		name: "hold",
		persist: false
	}, {
		name: "hasOperationSequence",
		persist: false
	}, {
		name: "increasedQuantity",
		type: "int",
		persist: false
	}, {
		name: "quantitySerial",
		type: "int",
		persist: false
	}, {
		name: "closable",
		persist: false
	}, {
		name: "deletable",
		persist: false
	}, {
		name: "mappingWarning",
		persist: false
	}, {
		name: "revisionControlled",
		type: "int",
		persist: false
	}, {
		name: "createSkeleton",
		persist: false
	}, {
		name: "anotherSOLink",
		persist: false
	}, {
		name: "defineUsl",
		persist: false
	}, {
		name: "usl",
		persist: false
	}, {
		name: "allowAddOperation",
		persist: false
	}, {
		name: "allowRemoveOperation",
		persist: false
	}, {
		name: "travelerTypeDescr",
		persist: false
	}, {
		name: "oneTravelerPerOrder",
		persist: false
	}, {
		name: "ATOShopOrderNumber",
		persist: false
	}, {
		name: "configurationCode",
		persist: false
	}, {
		name: "wipTravelerPerUnit",
		persist: false
	}, {
		name: "firstSerialNumber",
		persist: false
	}, {
		name: "lastSerialNumber",
		persist: false
	}, {
		name: "projectCode"
	}, {
		name: "organizationCode"
	}, {
		name: "partNumberDataIndex",
		persist: false
	}],
	associations: [{
		type: "hasMany",
		model: "Common.model.PartNumberModel",
		name: "partNumber",
		foreignKey: "partId",
		primaryKey: "id"
	}],
	validations: [{
		type: "presence",
		field: "ShopOrderNumber"
	}, {
		type: "presence",
		field: "partNumber"
	}, {
		type: "presence",
		field: "quantity"
	}, {
		type: "exclusion",
		field: "quantity",
		list: ["0"]
	}, {
		type: "presence",
		field: "quantity",
		matcher: "^d+$"
	}],
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "ShopOrderController.getShopOrderRelease"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			successProperty: "success",
			encode: false
		})
	},
	getPartNumber: function() {
		var a;
		if (typeof(this.partNumberStore) != "undefined" && this.partNumberStore.count() > 0) {
			a = this.partNumberStore.getAt(0)
		} else {
			if (typeof(this.data.partNumber) != null) {
				a = Ext.create("Common.model.PartNumberModel");
				a.set(this.data.partNumber)
			} else {
				a = Ext.create("Common.model.PartNumberModel")
			}
		}
		return a
	}
});
Ext.define("SO.model.LinkageModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "currentShopOrderKey"
	}, {
		name: "currentShopOrderNumber",
		persist: false
	}, {
		name: "nextShopOrderKey"
	}, {
		name: "nextShopOrderNumber",
		persist: false
	}, {
		name: "nextPartNumber",
		persist: false
	}, {
		name: "nextQuantity",
		persist: false
	}],
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "LinkageController.getLinkage"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			messageProperty: "message",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true
		})
	}
});
Ext.define("SO.ux.RowExpander", {
	extend: Ext.AbstractPlugin,
	lockableScope: "normal",
	alias: "plugin.rowexpander",
	rowBodyTpl: null,
	expandOnEnter: true,
	expandOnDblClick: true,
	selectRowOnExpand: false,
	rowBodyTrSelector: ".x-grid-rowbody-tr",
	rowBodyHiddenCls: "x-grid-row-body-hidden",
	rowCollapsedCls: "x-grid-row-collapsed",
	constructor: function() {
		var d = this,
			b, a, c;
		d.callParent(arguments);
		b = d.getCmp();
		d.recordsExpanded = {};
		if (!d.rowBodyTpl) {
			Ext.Error.raise("The 'rowBodyTpl' config is required and is not defined.")
		}
		d.rowBodyTpl = Ext.XTemplate.getTpl(d, "rowBodyTpl");
		a = this.rowBodyTpl;
		c = [{
			ftype: "rowbody",
			lockableScope: "normal",
			columnId: d.getHeaderId(),
			recordsExpanded: d.recordsExpanded,
			rowBodyHiddenCls: d.rowBodyHiddenCls,
			rowCollapsedCls: d.rowCollapsedCls,
			getAdditionalData: d.getRowBodyFeatureData,
			getRowBodyContents: function(e) {
				return a.applyTemplate(e)
			}
		}, {
			ftype: "rowwrap",
			lockableScope: "normal"
		}, {
			ftype: "feature",
			lockableScope: "locked",
			getAdditionalData: function(h, f, g, e) {
				if (!d.recordsExpanded[g.internalId]) {
					e.rowCls = (e.rowCls || "") + " " + d.rowCollapsedCls
				}
			}
		}];
		if (b.features) {
			b.features = Ext.Array.push(c, b.features)
		} else {
			b.features = c
		}
	},
	init: function(b) {
		var c = this,
			a = b;
		c.callParent(arguments);
		c.grid = b;
		c.view = b.getView();
		c.addExpander();
		c.bindView(c.view);
		if (a.ownerLockable) {
			a = a.ownerLockable;
			c.bindView(a.lockedGrid.getView())
		}
		a.on("beforereconfigure", c.beforeReconfigure, c)
	},
	beforeReconfigure: function(d, a, c, e, b) {
		var f = this.getHeaderConfig();
		f.locked = true;
		c.unshift(f)
	},
	addExpander: function() {
		var b = this,
			a = b.grid,
			c = b.getHeaderConfig();
		if (a.ownerLockable) {
			a = a.ownerLockable.lockedGrid;
			a.width += c.width
		}
		a.headerCt.insert(0, c)
	},
	getHeaderId: function() {
		if (!this.headerId) {
			this.headerId = Ext.id()
		}
		return this.headerId
	},
	getRowBodyFeatureData: function(d, a, b, g) {
		var c = this,
			e = c.self.prototype.getAdditionalData.apply(this, arguments),
			f = c.columnId;
		e.rowBodyColspan = e.rowBodyColspan;
		e.rowBody = c.getRowBodyContents(d);
		e.rowCls = c.recordsExpanded[b.internalId] ? "" : c.rowCollapsedCls;
		e.rowBodyCls = c.recordsExpanded[b.internalId] ? "" : c.rowBodyHiddenCls;
		e[f + "-tdAttr"] = ' valign="top" rowspan="2" ';
		if (g[f + "-tdAttr"]) {
			e[f + "-tdAttr"] += g[f + "-tdAttr"]
		}
		return e
	},
	bindView: function(a) {
		if (this.expandOnEnter) {
			a.on("itemkeydown", this.onKeyDown, this)
		}
		if (this.expandOnDblClick) {
			a.on("itemdblclick", this.onDblClick, this)
		}
	},
	onKeyDown: function(j, f, k, a, g) {
		if (g.getKey() == g.ENTER) {
			var b = j.store,
				c = j.getSelectionModel().getSelection(),
				h = c.length,
				d = 0;
			for (; d < h; d++) {
				a = b.indexOf(c[d]);
				this.toggleRow(a, c[d])
			}
		}
	},
	onDblClick: function(b, a, f, c, d) {
		this.toggleRow(c, a)
	},
	toggleRow: function(b, e) {
		var g = this,
			h = g.view,
			c = h.getNode(b),
			j = Ext.fly(c, "_rowExpander"),
			f = j.down(g.rowBodyTrSelector, true),
			d = j.hasCls(g.rowCollapsedCls),
			i = d ? "removeCls" : "addCls",
			a;
		Ext.suspendLayouts();
		j[i](g.rowCollapsedCls);
		Ext.fly(f)[i](g.rowBodyHiddenCls);
		g.recordsExpanded[e.internalId] = d;
		h.refreshSize();
		h.fireEvent(d ? "expandbody" : "collapsebody", j.dom, e, f);
		if (g.grid.ownerLockable) {
			h = g.grid.ownerLockable.lockedGrid.view;
			a = j.getHeight();
			j = Ext.fly(h.getNode(b), "_rowExpander");
			j.setHeight(a);
			j[i](g.rowCollapsedCls);
			h.refreshSize()
		}
		Ext.resumeLayouts(true)
	},
	getHeaderConfig: function() {
		var a = this;
		return {
			id: a.getHeaderId(),
			width: 24,
			lockable: false,
			sortable: false,
			resizable: false,
			draggable: false,
			hideable: false,
			menuDisabled: true,
			cls: Ext.baseCSSPrefix + "grid-header-special",
			renderer: function(c, b) {
				b.tdCls = Ext.baseCSSPrefix + "grid-cell-special";
				return '<div class="' + Ext.baseCSSPrefix + 'grid-row-expander">&#160;</div>'
			},
			processEvent: function(g, d, b, i, f, h, c) {
				if (g == "mousedown" && h.getTarget(".x-grid-row-expander")) {
					a.toggleRow(i, c);
					return a.selectRowOnExpand
				}
			}
		}
	}
});
Ext.define("SO.view.ShopOrderBrowser.GenericAttributesWindow", {
	extend: Ext.window.Window,
	alias: "widget.genericattributeswindow",
	id: "genericattributeswindow",
	width: 680,
	height: 400,
	resizable: false,
	model: true,
	constrain: true,
	renderTo: "xmain",
	buildDockedItems: function() {
		var a = {
			xtype: "toolbar",
			dock: "bottom",
			items: ["->",
			{
				xtype: "button",
				text: bundle.getMsg("socontrol.close"),
				action: "genAttrCancel",
				icon: path + "resources/images/16X16/close.png"
			}]
		};
		return a
	},
	initComponent: function() {
		var a = this;
		a.items = a.buildPanel();
		a.dockedItems = a.buildDockedItems();
		a.title = bundle.getMsg("socontrol.browser.genericAttributeList");
		a.border = 0;
		a.modal = true;
		a.layout = {
			type: "hbox",
			align: "center"
		};
		this.callParent(arguments)
	},
	buildPanel: function() {
		var a = Ext.create("Ext.grid.Panel", {
			width: 670,
			height: 340,
			autoScroll: true,
			layoutConfig: {
				scrollOffset: 19
			},
			store: "GenericAttributeStore",
			id: "genericattributegrid",
			columns: [{
				header: bundle.getMsg("socontrol.table"),
				flex: 1,
				dataIndex: "tableName",
				sortable: false
			}, {
				header: bundle.getMsg("socontrol.attributeName"),
				flex: 1,
				dataIndex: "attributeName",
				sortable: false
			}, {
				header: bundle.getMsg("socontrol.value"),
				flex: 1,
				dataIndex: "attrData",
				sortable: false
			}]
		});
		return a
	}
});
Ext.define("SO.view.ShopOrderBrowser.SelectSerialNumberWindow", {
	extend: Ext.window.Window,
	alias: "widget.selectserialnumberwindow",
	width: 360,
	height: 430,
	id: "selectserialnumberwindow",
	model: true,
	constrain: true,
	renderTo: "xmain",
	initComponent: function(b) {
		var a = this;
		a.items = a.buildPanel();
		a.title = bundle.getMsg("socontrol.browser.traveler.choose");
		a.border = 0;
		a.modal = true;
		a.layout = {
			type: "vbox",
			align: "center"
		};
		this.callParent(b)
	},
	buildPanel: function() {
		var a = Ext.create("Ext.grid.Panel", {
			style: {
				marginTop: "10px",
				marginLeft: "10px"
			},
			id: "selectSerialGrid",
			columns: [{
				header: bundle.getMsg("socontrol.release.print.serialNumber"),
				width: 110,
				flex: 1,
				sortable: true,
				dataIndex: "serialNumber"
			}],
			stripeRows: true,
			margins: "0 0 0 3",
			height: 300,
			width: 325,
			selModel: Ext.create("Ext.selection.CheckboxModel", {
				listeners: {
					selectionchange: function(f, e) {
						var d = Ext.getCmp("selectSerialOnPrintBt");
						if (e != null && e.length > 0) {
							d.setDisabled(false)
						} else {
							d.setDisabled(true)
						}
					}
				}
			})
		});
		var b = Ext.create("Ext.form.Panel", {
			style: {
				marginTop: "10px",
				marginLeft: "10px"
			},
			border: 0,
			layout: "column",
			items: [{
				xtype: "customtextfield",
				fieldLabel: bundle.getMsg("socontrol.filter"),
				labelAlign: "top",
				width: 296,
				id: "findSNToSelect",
				enableKeyEvents: true
			}, {
				xtype: "panel",
				layout: "vbox",
				width: 30,
				border: 0,
				style: {
					marginTop: "19px",
					marginLeft: "2px"
				},
				items: [{
					id: "clearSelectSerialButton",
					xtype: "button",
					icon: path + "resources/images/16X16/clear.png",
					action: "onClear",
					tooltip: bundle.getMsg("socontrol.clear"),
					align: "top",
					cls: "",
					style: {
						"min-width": "30px"
					},
					width: 30
				}]
			}]
		});
		var c = Ext.create("Ext.panel.Panel", {
			width: 350,
			height: 400,
			layout: "column",
			defaults: {
				flex: 1
			},
			items: [b, a],
			dockedItems: {
				xtype: "toolbar",
				dock: "bottom",
				items: ["->",
				{
					xtype: "button",
					text: bundle.getMsg("socontrol.browser.traveler.printToolTip"),
					action: "onPrint",
					disabled: true,
					id: "selectSerialOnPrintBt"
				}, {
					xtype: "button",
					text: bundle.getMsg("socontrol.cancel"),
					action: "onCancel"
				}]
			}
		});
		return c
	}
});
Ext.define("SO.model.ReleaseNotes", {
	extend: Ext.data.Model,
	fields: [{
		name: "shopOrderKey"
	}, {
		name: "notes"
	}, {
		name: "createUser"
	}, {
		name: "createDttm"
	}, {
		name: "updateUser"
	}, {
		name: "updateDttm"
	}],
	idProperty: "createDttm"
});
Ext.define("SO.view.util.AddSerialNumberWindow", {
	extend: Ext.window.Window,
	alias: "widget.addserialnumberwindow",
	width: 684,
	height: 495,
	id: "addserialnumberwindow",
	model: true,
	resizable: false,
	constrain: true,
	renderTo: "xmain",
	initComponent: function(b) {
		var a = this;
		a.items = a.buildPanel();
		a.title = bundle.getMsg("socontrol.addSerialNumber");
		a.border = 0;
		a.modal = true;
		a.layout = {
			type: "hbox",
			align: "center"
		};
		this.callParent(b)
	},
	buildPanel: function() {
		var a = Ext.create("Ext.grid.Panel", {
			style: {
				marginTop: "10px",
				marginLeft: "6px"
			},
			id: "results",
			multiSelect: true,
			viewConfig: {
				plugins: {
					pluginId: "gridviewdragdrop",
					ptype: "gridviewdragdrop",
					dragGroup: "firstGridDDGroup",
					dropGroup: "secondGridDDGroup"
				}
			},
			columns: [{
				header: bundle.getMsg("socontrol.serialNumber"),
				width: 110,
				flex: 1,
				sortable: true,
				dataIndex: "serialNumber"
			}, {
				header: bundle.getMsg("socontrol.unitStatusKey"),
				width: 50,
				sortable: true,
				dataIndex: "unitStatusKey"
			}, {
				header: bundle.getMsg("socontrol.location"),
				width: 120,
				flex: 1,
				sortable: true,
				dataIndex: "location"
			}],
			stripeRows: true,
			title: bundle.getMsg("socontrol.results"),
			margins: "0 2 0 0",
			height: 300,
			width: 325
		});
		var b = Ext.create("Ext.grid.Panel", {
			style: {
				marginTop: "10px",
				marginLeft: "10px"
			},
			id: "selected",
			viewConfig: {
				plugins: {
					pluginId: "gridviewdragdrop",
					ptype: "gridviewdragdrop",
					dragGroup: "secondGridDDGroup",
					dropGroup: "firstGridDDGroup"
				}
			},
			columns: [{
				header: bundle.getMsg("socontrol.serialNumber"),
				width: 110,
				flex: 1,
				sortable: true,
				dataIndex: "serialNumber"
			}, {
				header: bundle.getMsg("socontrol.unitStatusKey"),
				width: 50,
				sortable: true,
				dataIndex: "unitStatusKey",
				renderer: function(i, f, e, k, h, g, j) {
					return i == "0" ? "" : i
				}
			}, {
				header: bundle.getMsg("socontrol.location"),
				width: 120,
				flex: 1,
				sortable: true,
				dataIndex: "location"
			}],
			stripeRows: true,
			title: bundle.getMsg("socontrol.selected"),
			margins: "0 0 0 3",
			height: 300,
			width: 325
		});
		var c = Ext.create("Ext.form.Panel", {
			style: {
				marginTop: "10px",
				marginLeft: "6px"
			},
			border: 0,
			layout: "column",
			listeners: {
				afterrender: function() {
					Ext.getCmp("findSNToSelect").focus()
				}
			},
			items: [{
				xtype: "customtextfield",
				fieldLabel: bundle.getMsg("socontrol.filter"),
				labelAlign: "top",
				width: 660,
				style: {
					marginBottom: "5px"
				},
				id: "findSNByTypeToSelect",
				enableKeyEvents: true,
				hasfocus: true
			}, {
				xtype: "customtextfield",
				fieldLabel: bundle.getMsg("socontrol.scanOrTypeAdd"),
				labelAlign: "top",
				width: 623,
				id: "findSNToSelect",
				enableKeyEvents: true
			}, {
				xtype: "panel",
				layout: "vbox",
				height: 35,
				width: 30,
				border: 0,
				style: {
					marginTop: "21px",
					marginLeft: "6px"
				},
				items: [{
					id: "findSNToSelectButton",
					xtype: "button",
					icon: path + "resources/images/16X16/multipleSNs.png",
					action: "onAddMultiple",
					scope: this,
					align: "top",
					cls: "",
					style: {
						"min-width": "30px"
					},
					width: 30
				}]
			}]
		});
		var d = Ext.create("Ext.panel.Panel", {
			width: 674,
			height: 460,
			layout: "column",
			defaults: {
				flex: 1
			},
			items: [a, b, c],
			dockedItems: {
				xtype: "toolbar",
				dock: "bottom",
				items: ["->",
				{
					xtype: "button",
					text: bundle.getMsg("socontrol.reset"),
					action: "reset"
				}, {
					xtype: "button",
					action: "selectAll",
					text: bundle.getMsg("socontrol.selectAll"),
					handler: function() {
						if (a.store.getCount() > 0) {
							var f = a.store,
								e = b.store;
							e.add(f.getRange());
							e.sort("serialNumber", "ASC");
							f.removeAll()
						}
					}
				}, {
					xtype: "button",
					text: bundle.getMsg("socontrol.save"),
					action: "onSave"
				}, {
					xtype: "button",
					text: bundle.getMsg("socontrol.cancel"),
					action: "onCancel"
				}]
			}
		});
		return d
	}
});
Ext.define("Common.view.editor.SerialNumberGrid", {
	extend: Ext.grid.Panel,
	alias: "widget.serialnumbergrid",
	width: "100%",
	maxHeight: 200,
	autoScroll: true,
	id: "serialnumbergrid",
	customColumns: null,
	columnLines: true,
	scroll: "vertical",
	rowLines: true,
	maxHeight: 200,
	autoWidth: true,
	dataList: null,
	operation: null,
	name: null,
	cls: "custom-grid",
	buildColumns: function() {
		var a = [{
			header: bundle.getMsg("socontrol.release.print.serialNumber"),
			flex: 0.35,
			dataIndex: "serialNumber",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.release.traveler.quantity"),
			flex: 0.1,
			dataIndex: "quantity",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.release.traveler.unitType"),
			flex: 0.1,
			dataIndex: "unitType",
			sortable: true,
			renderer: function(f, c, b, h, e, d, g) {
				switch (f) {
				case -2:
					f = "Skeleton";
					break;
				case -1:
					f = "Dummy";
					break;
				case 0:
					f = "SFDC";
					break;
				case 8:
					f = "Non-Sn Batch";
					break;
				default:
					f = "[ " + f + " ]"
				}
				return f
			}
		}, {
			header: bundle.getMsg("socontrol.release.status"),
			flex: 0.1,
			dataIndex: "unitStatusKey",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.release.report.location"),
			flex: 0.25,
			dataIndex: "location",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.scanDateTime"),
			flex: 0.2,
			dataIndex: "dateTime",
			sortable: true
		}];
		return a
	},
	initComponent: function() {
		this.columns = this.customColumns == null ? this.buildColumns() : this.customColumns;
		this.columns = this.customColumns == null ? this.buildColumns() : this.customColumns;
		this.store = Ext.create("SO.store.SerialNumberStore");
		if (this.dataList != null) {
			this.store.loadData(this.dataList)
		}
		this.bbar = Ext.create("Ext.Custom.CustomPaging", {
			border: 0,
			store: this.store,
			displayInfo: false,
			beforePageText: bundle.getMsg("socontrol.page"),
			afterPageText: ""
		}), this.callParent(arguments)
	},
	viewConfig: {
		getRowClass: function(a, d, c, b) {
			if (a.get("isContainer")) {
				return "isContainer"
			}
		}
	}
});
Ext.define("SO.view.ShopOrderBrowser.ShopOrderInformation", {
	extend: Ext.form.Panel,
	alias: "widget.shoporderinformation",
	id: "shoporderinformation",
	autoScroll: true,
	loadMask: true,
	autoWidth: true,
	autoHeight: true,
	viewOnly: false,
	initComponent: function() {
		var a = this;
		a.items = a.buildPanel();
		a.buttons = a.buildButtons();
		a.on({
			afterrender: function() {
				checkPermissionsByContainer(a)
			}
		});
		this.callParent(arguments)
	},
	buildButtons: function() {
		var a = [{
			text: bundle.getMsg("socontrol.close"),
			action: "shoporderbrowser"
		}];
		return a
	},
	buildReleaseToolBar: function() {
		var a, b = this;
		a = Ext.create("Ext.toolbar.Toolbar", {
			items: ["->",
			{
				xtype: "button",
				text: bundle.getMsg("socontrol.save"),
				action: "save",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.saveReleaseNote",
				hidden: b.viewOnly
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.reset"),
				action: "reset",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.resetReleaseNote",
				hidden: b.viewOnly
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.browser.history"),
				action: "history",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.historyReleaseNote"
			}]
		});
		return a
	},
	buildLinkageToolBar: function() {
		var a, b = this;
		a = Ext.create("Ext.toolbar.Toolbar", {
			items: ["->",
			{
				xtype: "button",
				text: bundle.getMsg("socontrol.update"),
				action: "updateLinkage",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.updateLinkageInformation",
				icon: path + "resources/images/16X16/reload.png",
				hidden: b.viewOnly
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.remove"),
				action: "removeLinkage",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.removeLinkageInformation",
				icon: path + "resources/images/16X16/remove.png",
				hidden: b.viewOnly
			}]
		});
		return a
	},
	buildStandardToolBar: function() {
		var a, b = this;
		a = Ext.create("Ext.toolbar.Toolbar", {
			items: [{
				xtype: "button",
				text: bundle.getMsg("socontrol.release.wizard.summaryStep.soLinkage"),
				action: "updateLinkage",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.ShopOrderLinkage",
				icon: path + "resources/images/16X16/linkage.png",
				hidden: b.viewOnly
			}, {
				xtype: "tbseparator"
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.browser.displayGenericAtribute"),
				action: "displayGeneric",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.displayGenericAttributes",
				icon: path + "resources/images/16X16/displayGenAttr.png"
			}, {
				xtype: "tbseparator"
			}, {
				xtype: "button",
				text: "Remove from Hold",
				action: "removeFromHold",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.removeFromHold",
				icon: path + "resources/images/16X16/hold.png",
				id: "btnRemoveFromHold",
				hidden: b.viewOnly
			}, "->"]
		});
		return a
	},
	buildPanel: function() {
		var a;
		a = Ext.create("Ext.form.Panel", {
			defaults: {
				margin: "5 5 5 5",
				padding: "3 3 3 3",
				collapsible: true
			},
			items: [{
				xtype: "panel",
				title: bundle.getMsg("socontrol.browser.standardInformation"),
				tbar: this.buildStandardToolBar(),
				items: this.getStandardItemsPanel()
			}, {
				xtype: "panel",
				title: bundle.getMsg("socontrol.browser.oracleInformation"),
				id: "oracleinformationpanel",
				hidden: true,
				items: this.getOraclePanel()
			}, {
				xtype: "panel",
				title: bundle.getMsg("socontrol.browser.mappingInformation"),
				id: "mappinginformationpanel",
				hidden: true,
				items: this.getMappingPanel()
			}, {
				xtype: "form",
				title: bundle.getMsg("socontrol.releaseNotes"),
				bbar: this.buildReleaseToolBar(),
				items: this.getReleasePanel()
			}, {
				xtype: "form",
				title: bundle.getMsg("socontrol.browser.linkageInformation"),
				id: "linkageinformationpanel",
				hidden: true,
				bbar: this.buildLinkageToolBar(),
				items: this.getLinkagePanel()
			}, {
				xtype: "panel",
				title: bundle.getMsg("socontrol.browser.locationInfo"),
				id: "locationinformationpanel",
				hidden: true,
				items: this.getLocationPanel()
			}, {
				xtype: "panel",
				title: bundle.getMsg("socontrol.browser.serialNumberInfo"),
				id: "serialinformationpanel",
				hidden: true,
				tbar: this.buildUnstartedToolBar(),
				items: this.getSerialPanel()
			}]
		});
		return a
	},
	getStandardItemsPanel: function() {
		var a;
		a = Ext.create("Ext.form.Panel", {
			border: 0,
			autoWidth: true,
			autoHeight: true,
			layout: {
				type: "column",
				columns: 3
			},
			bodyPadding: "15, 15, 15, 15",
			defaults: {
				labelClsExtra: "labelFieldDisplayCss",
				labelWidth: 150,
				labelAlign: "right",
				columnWidth: 0.33
			},
			items: [{
				xtype: "displayfield",
				fieldLabel: "Shop Order Number",
				name: "shopOrderNumber"
			}, {
				xtype: "displayfield",
				fieldLabel: "Boards Per Panel",
				name: "boardsPerPanel"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.label.oraclePartNumber"),
				name: "oraclePartNumber"
			}, {
				xtype: "displayfield",
				fieldLabel: "Part Number",
				name: "partNumber"
			}, {
				xtype: "displayfield",
				fieldLabel: "Number of Panels",
				name: "numberOfPanels"
			}, {
				xtype: "displayfield",
				fieldLabel: "Status Date",
				name: "statusDate"
			}, {
				xtype: "displayfield",
				fieldLabel: "Status",
				name: "shopOrderStatus"
			}, {
				xtype: "displayfield",
				fieldLabel: "Increased Quantity",
				name: "increasedQuantity"
			}, {
				xtype: "displayfield",
				fieldLabel: "Start Date",
				name: "startDate"
			}, {
				xtype: "displayfield",
				fieldLabel: "Revision",
				name: "revision"
			}, {
				xtype: "displayfield",
				fieldLabel: "Starting Serial Number",
				name: "startingSerialNumber"
			}, {
				xtype: "displayfield",
				fieldLabel: "Completion Date",
				name: "completionDate"
			}, {
				xtype: "displayfield",
				fieldLabel: "User ID",
				name: "userId"
			}, {
				xtype: "displayfield",
				fieldLabel: "Ending Serial Number",
				name: "endingSerialNumber"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.release.userDefined"),
				name: "userDefined"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.orgCode"),
				name: "organizationCode"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.projCode"),
				name: "projectCode"
			}]
		});
		return a
	},
	getOraclePanel: function() {
		var b;
		var a;
		var c;
		a = Ext.create("Ext.panel.Panel", {
			width: 500,
			height: 120,
			border: 0,
			layout: {
				type: "table",
				columns: 3
			},
			defaults: {
				labelClsExtra: "labelFieldDisplayCss"
			},
			items: [{
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.label.oracleStatus"),
				name: "oracleStatus",
				labelWidth: 150,
				labelAlign: "right"
			}, {
				xtype: "tbspacer",
				width: 20
			}, {
				xtype: "displayfield",
				fieldLabel: "Change Date",
				name: "changeDate",
				labelWidth: 150,
				labelAlign: "right"
			}, {
				xtype: "displayfield",
				fieldLabel: "On Hold",
				name: "isOnHold",
				labelWidth: 150,
				labelAlign: "right"
			}, {
				xtype: "tbspacer",
				width: 20
			}, {
				xtype: "displayfield",
				fieldLabel: "Transfer On Hold",
				name: "transferOnHold",
				labelWidth: 150,
				labelAlign: "right"
			}]
		});
		c = Ext.create("Ext.grid.Panel", {
			width: 550,
			height: 115,
			autoScroll: true,
			id: "oracleinfogrid",
			columns: [{
				header: "Operation Sequence",
				flex: 1,
				dataIndex: "description",
				sortable: false,
				renderer: function(h, e, d, j, g, f, i) {
					return d.toString()
				}
			}]
		});
		b = Ext.create("Ext.toolbar.Toolbar", {
			autoWidth: true,
			autoHeight: true,
			baseCls: "toolbarColor",
			items: [a,
			{
				xtype: "tbfill"
			},
			c]
		});
		return b
	},
	getMappingPanel: function() {
		var b;
		var a;
		var c;
		a = Ext.create("Ext.panel.Panel", {
			width: 500,
			height: 120,
			border: 0,
			layout: {
				type: "table",
				columns: 1
			},
			defaults: {
				labelClsExtra: "labelFieldDisplayCss"
			},
			items: [{
				xtype: "displayfield",
				fieldLabel: "Type",
				name: "mapType",
				labelWidth: 150,
				labelAlign: "right"
			}]
		});
		c = Ext.create("Ext.grid.Panel", {
			width: 550,
			height: 115,
			autoScroll: true,
			id: "mappinginfogrid",
			columns: [{
				header: "Operation Sequence",
				flex: 1,
				dataIndex: "mapOpSeq",
				sortable: true,
				renderer: function(k, e, j, m, f, l, d) {
					var g = Ext.getCmp("oracleinfogrid"),
						i = null,
						h = null;
					if (typeof g != "undefined") {
						i = g.getStore();
						if (i != null) {
							if (i.data.length > 0) {
								h = i.data.items[i.findExact("opseq", k.toString())]
							}
						}
					}
					if (j.get("invalid")) {
						e.tdCls = " invalidBackground"
					}
					return h != null ? h.toStringShort() : k
				}
			}, {
				header: "Location/Process Name",
				flex: 1,
				dataIndex: "locProcText",
				sortable: false,
				renderer: function(h, e, d, j, g, f, i) {
					if (d.get("invalid")) {
						e.tdCls = " invalidBackground"
					}
					return h
				}
			}]
		});
		b = Ext.create("Ext.toolbar.Toolbar", {
			autoWidth: true,
			autoHeight: true,
			baseCls: "toolbarColor",
			items: [a,
			{
				xtype: "tbfill"
			},
			c]
		});
		return b
	},
	getReleasePanel: function() {
		var c;
		var a;
		var b;
		var d = this;
		a = Ext.create("Ext.panel.Panel", {
			autoWidth: true,
			autoHeight: true,
			border: 0,
			layout: {
				type: "table",
				columns: 3
			},
			defaults: {
				labelClsExtra: "labelFieldDisplayCss"
			},
			items: [{
				xtype: "customtextfield",
				disabled: true,
				fieldLabel: "Created By",
				name: "createUser",
				labelAlign: "right"
			}, {
				xtype: "tbspacer",
				width: 150
			}, ,
			{
				xtype: "customtextfield",
				disabled: true,
				fieldLabel: "Date/Time",
				name: "createDttm",
				labelAlign: "right"
			}]
		});
		b = Ext.create("Ext.form.field.TextArea", {
			width: "100%",
			height: 100,
			name: "notes",
			maxLength: 30000,
			readOnly: d.viewOnly
		});
		c = Ext.create("Ext.form.Panel", {
			autoWidth: true,
			autoHeight: true,
			id: "releaseinfo",
			baseCls: "toolbarColor",
			items: [b, a]
		});
		return c
	},
	getLinkagePanel: function() {
		fields = Ext.create("Ext.form.Panel", {
			autoWidth: true,
			autoHeight: true,
			border: 0,
			id: "linkageinfoform",
			layout: {
				type: "table",
				columns: 5
			},
			defaults: {
				labelClsExtra: "labelFieldDisplayCss"
			},
			items: [{
				xtype: "displayfield",
				labelAlign: "right",
				labelWidth: 150,
				fieldLabel: "Next Shop Order Number",
				name: "nextShopOrderNumber"
			}, {
				xtype: "tbspacer",
				width: 150
			}, {
				xtype: "displayfield",
				labelAlign: "right",
				labelWidth: 150,
				fieldLabel: "Part Number",
				name: "nextPartNumber"
			}, {
				xtype: "tbspacer",
				width: 150
			}, {
				xtype: "displayfield",
				labelAlign: "right",
				labelWidth: 150,
				fieldLabel: "Number of Panels",
				name: "nextQuantity"
			}]
		});
		panel = Ext.create("Ext.form.Panel", {
			autoWidth: true,
			autoHeight: true,
			id: "linkageinfo",
			baseCls: "toolbarColor",
			items: [fields]
		});
		return panel
	},
	getLocationPanel: function() {
		var a;
		var b;
		b = Ext.create("Ext.grid.Panel", {
			width: "100%",
			height: 115,
			autoScroll: true,
			id: "locationinfogrid",
			columns: [{
				header: "Location Name",
				flex: 1,
				dataIndex: "locationDesc",
				sortable: false
			}, {
				header: "Serial Status",
				flex: 1,
				dataIndex: "unitStatusDesc",
				sortable: false
			}, {
				header: "Serial Qty",
				flex: 1,
				dataIndex: "serialQty",
				sortable: false
			}]
		});
		a = Ext.create("Ext.form.Panel", {
			width: "100%",
			autoHeight: true,
			baseCls: "toolbarColor",
			items: [b]
		});
		return a
	},
	buildUnstartedToolBar: function() {
		var a, b = this;
		a = Ext.create("Ext.toolbar.Toolbar", {
			items: [{
				xtype: "button",
				id: "btnAuxRelease",
				text: "Auxiliary Release",
				action: "auxiliaryRelease",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.auxiliaryRelease",
				icon: path + "resources/images/16X16/release.png",
				disabled: true,
				hidden: b.viewOnly
			}, {
				xtype: "button",
				id: "btnDeleteUnstarted",
				text: "Delete Unstarted Units",
				action: "deleteUnstarted",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.deleteUnstartedUnits",
				icon: path + "resources/images/16X16/delete.png",
				disabled: true,
				hidden: b.viewOnly
			}, {
				icon: path + "resources/images/16X16/bom.png",
				text: bundle.getMsg("socontrol.browser.view.bomInfo"),
				id: "bomToolbar",
				action: "bomInformation",
				disabled: false
			}, "->",
			{
				xtype: "button",
				text: "Print/Export Unit Status Details",
				action: "printUnitStatusDetails",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.prntExpUnitsStatusDetails",
				icon: path + "resources/images/16X16/print.png"
			}, {
				xtype: "tbseparator"
			}, {
				xtype: "button",
				text: "Print Labels",
				action: "printLabels",
				actionKey: "shopOrder.shopOrderBrowser.shopOrderInformation.printLabels",
				icon: path + "resources/images/16X16/print.png"
			}]
		});
		return a
	},
	getSerialPanel: function() {
		var a;
		var b;
		b = Ext.widget("serialnumbergrid");
		a = Ext.create("Ext.form.Panel", {
			autoWidth: true,
			autoHeight: true,
			baseCls: "toolbarColor",
			items: [b]
		});
		return a
	}
});
Ext.define("SO.store.ShopOrderSelectionStore", {
	extend: Ext.data.Store,
	model: "SO.model.ShopOrderModel",
	remoteSort: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "GenericFetchController.getShopOrdersToLink"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	}
});
Ext.define("SO.view.ShopOrderBrowser.ShopOrderSelectionFilter", {
	extend: Ext.panel.Panel,
	alias: "widget.shoporderselectionfilter",
	height: "100%",
	width: "100%",
	initComponent: function() {
		var a = this;
		a.store = Ext.getStore("ShopOrderSelectionStore");
		a.items = a.buildPanel();
		this.callParent(arguments)
	},
	listeners: {
		afterrender: function() {
			Ext.getCmp("soNumberFieldId").focus()
		}
	},
	buildPanel: function() {
		var a = [{
			xtype: "container",
			layout: {
				type: "vbox",
				align: "stretch"
			},
			width: "100%",
			border: 0,
			items: [{
				xtype: "panel",
				layout: {
					type: "column"
				},
				border: 0,
				style: {
					padding: "10px",
					marginRight: "0px"
				},
				items: [{
					xtype: "panel",
					border: 0,
					baseCls: "float_right_panel",
					items: [{
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.soNumber"),
						labelAlign: "top",
						name: "soNumberField",
						idProperty: "soNumberField",
						width: 130,
						id: "soNumberFieldId",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.partNumber"),
						labelAlign: "top",
						name: "pNumberField",
						width: 130,
						idProperty: "pNumberField",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "panel",
						layout: {
							type: "vbox"
						},
						baseCls: "float_right_panel",
						style: {
							marginLeft: "15px"
						},
						border: 0,
						items: [{
							xtype: "button",
							id: "soSelectionFilter",
							text: bundle.getMsg("socontrol.filter"),
							action: "soSelectionFilter",
							iconCls: "filterButtonIcon"
						}, {
							xtype: "tbspacer",
							height: 5
						}, {
							xtype: "button",
							id: "soSelectionClear",
							text: bundle.getMsg("socontrol.clear"),
							action: "soSelectionClear",
							iconCls: "clearButtonIcon"
						}]
					}]
				}]
			}]
		}];
		return a
	}
});
Ext.define("SO.view.ShopOrderBrowser.ShopOrderSelectionWindow", {
	extend: Ext.window.Window,
	alias: "widget.shoporderselectionwindow",
	id: "shoporderselectionwindow",
	width: 680,
	height: 400,
	resizable: false,
	model: true,
	constrain: true,
	renderTo: "xmain",
	buildDockedItems: function() {
		var a = {
			xtype: "toolbar",
			dock: "bottom",
			items: ["->",
			{
				xtype: "button",
				text: bundle.getMsg("socontrol.ok"),
				action: "soSelectionOK",
				icon: path + "resources/images/16X16/ok.png"
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.cancel"),
				action: "soSelectionCancel",
				icon: path + "resources/images/16X16/cancel.png"
			}]
		};
		return a
	},
	initComponent: function() {
		var a = this;
		a.items = a.buildPanel();
		a.dockedItems = a.buildDockedItems();
		a.title = bundle.getMsg("socontrol.selection");
		a.border = 0;
		padding: 0,
		a.modal = true;
		a.layout = {
			type: "hbox",
			align: "center"
		};
		this.callParent(arguments)
	},
	buildPanel: function() {
		var c = Ext.widget("shoporderselectionfilter");
		var b = Ext.create("Ext.grid.Panel", {
			width: 671,
			height: 263,
			id: "soselectiongrid",
			columns: [{
				header: bundle.getMsg("socontrol.soNumber"),
				flex: 1,
				dataIndex: "shopOrderNumber",
				sortable: true
			}, {
				header: bundle.getMsg("socontrol.partNumber"),
				flex: 1,
				sortable: true,
				dataIndex: "partNumberDataIndex"
			}, {
				header: bundle.getMsg("socontrol.maintenance.partNumber.quantity"),
				flex: 1,
				dataIndex: "quantity",
				sortable: true
			}],
			selModel: Ext.create("Ext.selection.CheckboxModel", {
				mode: "SINGLE"
			})
		});
		var a = Ext.create("Ext.form.Panel", {
			width: 671,
			border: 0,
			id: "soselectinfo",
			baseCls: "toolbarColor",
			items: [c, b]
		});
		return a
	}
});
Ext.define("SO.view.ShopOrderBrowser.PrintTravelerFilter", {
	extend: Ext.panel.Panel,
	alias: "widget.printtravelerfilter",
	height: "100%",
	width: "100%",
	initComponent: function() {
		var a = this;
		a.store = Ext.getStore("PrintTravelerStore");
		a.border = 0;
		a.items = a.buildPanel();
		this.callParent(arguments)
	},
	listeners: {
		afterrender: function() {
			Ext.getCmp("soNumberField").focus()
		}
	},
	buildPanel: function() {
		var a = [{
			xtype: "container",
			layout: {
				type: "vbox",
				align: "stretch"
			},
			width: "100%",
			border: 0,
			items: [{
				xtype: "panel",
				layout: {
					type: "column"
				},
				border: 0,
				style: {
					padding: "10px",
					marginRight: "0px"
				},
				items: [{
					xtype: "panel",
					border: 0,
					baseCls: "float_right_panel",
					items: [{
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.soNumber"),
						labelAlign: "top",
						name: "soNumberField",
						idProperty: "soNumberField",
						id: "soNumberField",
						width: 130,
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.partNumber"),
						labelAlign: "top",
						name: "pNumberField",
						idProperty: "pNumberField",
						width: 130,
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "combobox",
						fieldLabel: bundle.getMsg("socontrol.browser.traveler.travelerType"),
						labelAlign: "top",
						name: "soTravelerTypeField",
						idProperty: "soTravelerTypeField",
						valueField: "id",
						displayField: "description",
						value: -1,
						valueNotFoundText: "Loading...",
						forceSelection: true,
						width: 130,
						cls: "comboFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "comboFilterCss",
						editable: false,
						queryMode: "local",
						store: Ext.create("Ext.data.Store", {
							fields: ["prnTrav", "description"],
							autoLoad: true,
							proxy: {
								type: "ajax",
								format: "json",
								url: window.windowSOContext.ajaxURL,
								appendId: false,
								extraParams: {
									resourceID: "ShopOrderController.getTravelerTypeStore"
								},
								reader: {
									root: "data",
									totalProperty: "totalCount"
								}
							},
							listeners: {
								load: function(c) {
									c.sort("description", "ASC");
									var b = Ext.ComponentQuery.query("printtravelerlist combobox");
									b[0].setValue(-1)
								}
							}
						})
					}, {
						xtype: "panel",
						layout: {
							type: "vbox"
						},
						id: "painelButtons",
						baseCls: "float_right_panel",
						style: {
							marginLeft: "15px"
						},
						border: 0,
						items: [{
							xtype: "button",
							id: "filter",
							text: bundle.getMsg("socontrol.filter"),
							action: "printTravelerFilter",
							iconCls: "filterButtonIcon"
						}, {
							xtype: "tbspacer",
							height: 5
						}, {
							xtype: "button",
							id: "clear",
							text: bundle.getMsg("socontrol.clear"),
							action: "printTravelerClear",
							iconCls: "clearButtonIcon"
						}]
					}]
				}]
			}]
		}];
		return a
	}
});
Ext.define("SO.view.ShopOrderBrowser.PrintTravelerList", {
	extend: Ext.grid.Panel,
	alias: "widget.printtravelerlist",
	id: "printtravelerlist",
	autoWidth: true,
	autoHeight: true,
	initComponent: function() {
		var a = this;
		a.border = 0;
		a.stripeRows = false;
		a.columns = a.buildColumns();
		a.bbar = a.buildBottomBar();
		a.selModel = Ext.create("Ext.selection.CheckboxModel", {
			mode: "SINGLE",
			showHeaderCheckbox: false,
			listeners: {
				selectionchange: function(d, c) {
					var b = Ext.getCmp("printTravelerToolbar");
					if (!b) {
						b = Ext.getCmp("reprintTravelerToolbar")
					}
					if (c[0] != null) {
						b.setDisabled(false)
					} else {
						b.setDisabled(true)
					}
				}
			}
		});
		a.callParent(arguments)
	},
	statics: {
		getPrintTravelerStore: function(b) {
			var a = Ext.getStore("PrintTravelerStore");
			a.getProxy().extraParams.isReprint = b;
			return a
		},
		buildDockedItemsBar: function(b) {
			var a;
			if (b == false) {
				a = Ext.create("Ext.toolbar.Toolbar", {
					items: [{
						icon: path + "resources/images/16X16/print.png",
						text: bundle.getMsg("socontrol.browser.traveler.printTraveler"),
						id: "printTravelerToolbar",
						action: "onPrintTravelerFromList",
						scope: this,
						disabled: true
					}]
				})
			} else {
				a = Ext.create("Ext.toolbar.Toolbar", {
					items: [{
						icon: path + "resources/images/16X16/print.png",
						text: bundle.getMsg("socontrol.browser.traveler.reprintTraveler"),
						id: "reprintTravelerToolbar",
						action: "onReprintTravelerFromList",
						scope: this,
						disabled: true
					}]
				})
			}
			return a
		},
		buildFilterTopBar: function(c) {
			var a = bundle.getMsg("socontrol.browser.traveler.printTitle");
			if (c == true) {
				a = bundle.getMsg("socontrol.browser.traveler.reprintTitle")
			}
			var b;
			b = Ext.create("SO.view.ShopOrderBrowser.PrintTravelerFilter", {
				title: a
			});
			return b
		}
	},
	buildColumns: function() {
		var a = [];
		a = [{
			header: bundle.getMsg("socontrol.release.soNumber"),
			width: 120,
			flex: 1,
			sortable: true,
			dataIndex: "shopOrderNumber"
		}, {
			header: bundle.getMsg("socontrol.maintenance.partNumber.partNumber"),
			flex: 1,
			sortable: true,
			width: 140,
			dataIndex: "partId",
			renderer: function(f, c, b, h, e, d, g) {
				return b.getPartNumber().get("partNumber")
			}
		}, {
			header: bundle.getMsg("socontrol.quantityTable"),
			width: 60,
			flex: 1,
			dataIndex: "quantity",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.browser.traveler.travelerType"),
			flex: 1,
			sortable: true,
			dataIndex: "travelerTypeDescr"
		}];
		return a
	},
	buildBottomBar: function() {
		var a;
		a = Ext.create("Ext.Custom.CustomPaging", {
			border: 0,
			store: Ext.getStore("PrintTravelerStore"),
			displayInfo: false,
			beforePageText: bundle.getMsg("socontrol.page"),
			afterPageText: ""
		});
		a.add("->");
		a.add({
			tooltip: bundle.getMsg("button.back"),
			text: bundle.getMsg("button.back"),
			scope: this,
			action: "backShopOrderBrowserBottom",
			id: "backShopOrderBrowserBottom"
		});
		return a
	}
});
Ext.define("SO.store.ShopOrderBrowserStore", {
	extend: Ext.data.Store,
	model: "SO.model.ShopOrderModel",
	pageSize: 50,
	remoteSort: false,
	autoLoad: false
});
Ext.define("SO.store.HistoryNotesStore", {
	extend: Ext.data.Store,
	model: "SO.model.ReleaseNotes",
	remoteSort: false,
	autoLoad: false,
	sorters: [{
		property: "createDttm",
		direction: "DESC"
	}],
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "ReleaseNotesController.findAllReleaseNotes"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			messageProperty: "message",
			idProperty: "id",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true
		})
	},
	listeners: {
		write: function(b, a) {
			var c = Ext.decode(a.response.responseText);
			if (c.success) {
				Ext.MessageBox.show({
					title: "",
					msg: c.message,
					icon: Ext.MessageBox.INFO,
					buttons: Ext.Msg.OK
				})
			} else {
				Ext.MessageBox.show({
					title: "",
					msg: c.message,
					icon: Ext.MessageBox.ERROR,
					buttons: Ext.Msg.OK
				})
			}
		}
	}
});
Ext.define("SO.store.LinkageStore", {
	extend: Ext.data.Store,
	model: "SO.model.LinkageModel",
	remoteSort: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			messageProperty: "message",
			idProperty: "id",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true
		})
	},
	listeners: {
		write: function(b, a) {
			var c = Ext.decode(a.response.responseText);
			if (c.success) {
				Ext.MessageBox.show({
					title: "",
					msg: c.message,
					icon: Ext.MessageBox.INFO,
					buttons: Ext.Msg.OK
				})
			} else {
				Ext.MessageBox.show({
					title: "",
					msg: c.message,
					icon: Ext.MessageBox.ERROR,
					buttons: Ext.Msg.OK
				})
			}
		}
	}
});
Ext.define("SO.model.GenericAttributeModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "tableName"
	}, {
		name: "attributeName"
	}, {
		name: "attrData"
	}, {
		name: "location"
	}, {
		name: "locationKey"
	}, {
		name: "mask"
	}, {
		name: "type"
	}, {
		name: "removed"
	}, {
		name: "released"
	}, {
		name: "step"
	}, {
		name: "processName"
	}, {
		name: "processId"
	}, {
		name: "line"
	}, {
		name: "nameKey"
	}]
});
Ext.define("SO.store.GenericAttributeStore", {
	extend: Ext.data.Store,
	model: "SO.model.GenericAttributeModel",
	remoteSort: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "GenericFetchController.getGenericAttributes"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			messageProperty: "message",
			totalProperty: "totalCount",
			root: "data"
		})
	}
});
Ext.define("SO.controller.ShopOrderBrowserController", {
	extend: Ext.app.Controller,
	stores: ["ShopOrderBrowserStore", "HistoryNotesStore", "ShopOrderSelectionStore", "SerialNumberStore", "LinkageStore", "GenericAttributeStore"],
	views: ["ShopOrderBrowser.ShopOrderInformation", "ShopOrderBrowser.ReleaseNotesHistoryWindow", "ShopOrderBrowser.ShopOrderSelectionWindow", "ShopOrderBrowser.GenericAttributesWindow", "ShopOrderBrowser.PrintTravelerList", "ShopOrderBrowser.PrintLabelsWindow", "util.AddSerialNumberWindow", "ShopOrderBrowser.SelectSerialNumberWindow", "ShopOrderBrowser.PrintLabelsWindow"],
	refs: [{
		selector: "shoporderinformation",
		ref: "shopOrderInfo"
	}],
	init: function() {
		this.control({
			"shoporderinformation button[action=shoporderbrowser]": {
				click: this.onCloseWindow
			},
			"shoporderinformation button[action=save]": {
				click: this.onSaveWindow
			},
			"shoporderinformation button[action=reset]": {
				click: this.onResetWindow
			},
			"shoporderinformation button[action=history]": {
				click: this.onHistoryClick
			},
			"shoporderinformation button[action=updateLinkage]": {
				click: this.onUpdateLinkage
			},
			"shoporderinformation button[action=deleteUnstarted]": {
				click: this.onDeleteUnstarted
			},
			"shoporderinformation button[action=auxiliaryRelease]": {
				click: this.onAuxiliaryRelease
			},
			"shoporderinformation button[action=bomInformation]": {
				click: this.onBomInformation
			},
			"shoporderinformation button[action=displayGeneric]": {
				click: this.onDisplayGeneric
			},
			"shoporderinformation button[action=removeLinkage]": {
				click: this.onRemoveLinkage
			},
			"shoporderinformation button[action=printLabels]": {
				click: this.onPrintLabels
			},
			"shoporderinformation button[action=printUnitStatusDetails]": {
				click: this.printUnitStatusDetails
			},
			"shoporderselectionwindow button[id=soSelectionFilter]": {
				click: this.doFilter
			},
			"shoporderselectionwindow button[id=soSelectionClear]": {
				click: this.doClear
			},
			"shoporderselectionwindow button[action=soSelectionCancel]": {
				click: this.onCancelClick
			},
			"genericattributeswindow button[action=genAttrCancel]": {
				click: this.onCancelClick
			},
			"shoporderselectionwindow button[action=soSelectionOK]": {
				click: this.onSelectionOkClick
			},
			"printtravelerlist button[action=onPrintTravelerFromList]": {
				click: this.onPrintTravelerFromList
			},
			"printtravelerlist button[action=onReprintTravelerFromList]": {
				click: this.onReprintTravelerFromList
			},
			"#selectserialnumberwindow button[action=onCancel]": {
				click: this.onSelectCancel
			},
			"#selectserialnumberwindow button[action=onClear]": {
				click: this.onSelectClear
			},
			"#selectserialnumberwindow button[action=onPrint]": {
				click: this.printWipOrOneTravelerPerUnit
			},
			"#selectserialnumberwindow textfield[id=findSNToSelect]": {
				keyup: function(c, b) {
					this.findSNToSelect(c.getValue())
				}
			},
			"printlabelswindow button[action=onPrint]": {
				click: this.onPrintLabel
			},
			"printlabelswindow button[action=onSelectSnBtn]": {
				click: this.onSelectSerialToPrint
			},
			"#printlabelselectserialnbrs grid[id=results]": {
				scope: this,
				itemdblclick: function(h, g, d, b, f, c) {
					toStore = Ext.getCmp("selected").store;
					if (b > -1) {
						this.itemDoubleClick(Ext.getCmp("results").store, Ext.getCmp("selected").store, g)
					}
				}
			},
			"#printlabelselectserialnbrs grid[id=selected]": {
				scope: this,
				itemdblclick: function(h, g, d, b, f, c) {
					if (b > -1) {
						this.itemDoubleClick(Ext.getCmp("selected").store, Ext.getCmp("results").store, g)
					}
				}
			},
			"#printlabelselectserialnbrs button[action=onCancel]": {
				click: this.onSelectPrintLabelCancel
			},
			"#printlabelselectserialnbrs button[action=reset]": {
				click: this.resetFromPrintLabelSelectSN
			},
			"#printlabelselectserialnbrs textfield[id=findSNByTypeToSelect]": {
				keyup: function(c, b) {
					this.findSNByTypeAddToSelect(c.getValue())
				}
			},
			"#printlabelselectserialnbrs textfield[id=findSNToSelect]": {
				keypress: function(c, b) {
					if (b.getKey() == Ext.EventObject.ENTER && c.value != null && c.value != "") {
						this.findSNAddToSelect(c.getValue())
					}
				}
			},
			"#printlabelselectserialnbrs button[action=onAddMultiple]": {
				click: this.onAddMultiple
			},
			"#printlabelselectserialnbrs button[action=onSave]": {
				click: this.onSavePrintLabelSelectSN
			},
			"#addmultiplefromprintlabel button[action=onOkAddMultipleSN]": {
				click: this.onOkAddMultipleSN
			},
			"#addmultiplefromprintlabel button[action=onCancelAddMultipleSN]": {
				click: this.onCancelAddMultipleSN
			},
			"#shoporderinformation button[action=removeFromHold]": {
				click: this.removeFromHold
			},
			"#shoporderbrowserlist button[action=printtravelerlist]": {
				click: this.onPrintTravelerList
			},
			"#shoporderbrowserlist button[action=reprinttravelerlist]": {
				click: this.onRePrintTravelerList
			},
			"printtravelerlist button[action=backShopOrderBrowserBottom]": {
				click: this.onBackShopOrderBrowser
			},
			"#shoporderbrowserlist button[action=printFile]": {
				click: this.onPrintFile
			}
		});
		var a = null;
		this.application.on({
			onShopOrderInfo: this.onShopOrderInfo,
			onFinishAuxiliaryRelease: this.onFinishAuxiliaryRelease,
			onCompleteAppendSerialTree: this.onCompleteAppendSerialTree,
			scope: this
		})
	},
	onPrintFile: function(e, a, b) {
		var c = window.windowSOContext.ajaxURL,
			c = c + (c.indexOf("?") > -1 ? "&" : "?") + Ext.urlEncode(e),
			d = window.open(c);
		if (d == null || typeof(d) == "undefined") {
			b.getEl().unmask();
			Ext.CustomMessageBox.msg(b.id, bundle.getMsg("socontrol.message.error"), bundle.getMsg("error.labelDownload.popUpBlockers"))
		} else {
			d.onload = function() {
				if (d != null && typeof(d) != "undefined") {
					d.print()
				}
			};
			if (a != null) {
				a()
			}
		}
	},
	onPrintTravelerList: function() {
		this.application.controllers.get("ShopOrderController").pushScreen("printtravelerlist", null)
	},
	onRePrintTravelerList: function() {
		this.application.controllers.get("ShopOrderController").pushScreen("printtravelerlist", "reprinttravelerlistmenubtn")
	},
	onBackShopOrderBrowser: function() {
		this.application.controllers.get("ShopOrderController").pushScreen("shoporderbrowserlist", null)
	},
	onPrintLabels: function() {
		var a = this.getShopOrderInfo().getRecord();
		Ext.widget("printlabelswindow", {
			shopOrderId: a.internalId,
			partKey: a.get("partId"),
			partNumber: a.get("partNumber"),
			shopOrderNumber: a.get("shopOrderNumber")
		}).show();
		Ext.getCmp("printlabelsform").getForm().isValid()
	},
	onSelectSerialToPrint: function() {
		var e = Ext.widget("addserialnumberwindow", {
			id: "printlabelselectserialnbrs",
			title: bundle.getMsg("socontrol.release.print.selectSerialNumbers")
		}),
			c = Ext.getCmp("selected"),
			a = Ext.getCmp("results"),
			b = Ext.create("SO.store.SerialNumberStore"),
			d = Ext.getCmp("printlabelswindow");
		c.reconfigure(Ext.create("SO.store.SerialNumberStore"));
		if (d.sn_data) {
			b.loadData(d.sn_data);
			a.reconfigure(b);
			this.onLoadSerialNumberToPrintLabel()
		} else {
			b.proxy.extraParams.shopOrderId = d.shopOrderId;
			b.proxy.extraParams.resourceID = "SerialNumberController.getFindAllSerialNumberView";
			b.proxy.extraParams.ignoreLimit = true;
			b.load({
				scope: this,
				callback: function() {
					this.onLoadSerialNumberToPrintLabel()
				}
			});
			a.reconfigure(b)
		}
		e.show()
	},
	itemDoubleClick: function(a, b, c) {
		a.remove(c);
		b.add(c)
	},
	onLoadSerialNumberToPrintLabel: function() {
		var b = Ext.ComponentQuery.query("#serialNumberHiddenList");
		if (b[0].getValue() != null && b[0].getValue() != "") {
			var c = Ext.decode(b[0].getValue());
			if (c != null && c.length > 0) {
				var a;
				for (a = 0; a < c.length; a++) {
					if (c[a] != "") {
						this.findSNAddToSelect(c[a])
					}
				}
			}
		}
	},
	onCancelClick: function(a) {
		a.up("window").close()
	},
	onSelectionOkClick: function(b) {
		scope: this;
		var d = Ext.getCmp("soselectiongrid");
		var f = d.getSelectionModel().getSelection()[0];
		var c = b.up("window");
		var e = Ext.create("SO.model.LinkageModel");
		if (typeof(f) != "undefined") {
			var a;
			if (typeof(this.getShopOrderInfo()) != "undefined") {
				a = this.getShopOrderInfo().getRecord()
			} else {
				a = releaseWizardModel.data.shopOrder
			}
			e.set("currentShopOrderKey", a.internalId);
			e.set("nextShopOrderKey", f.data.id);
			e.getProxy().extraParams.isUpdate = true;
			Ext.Msg.show({
				title: bundle.getMsg("socontrol.confirm"),
				msg: bundle.getMsg("socontrol.message.link.changeLink"),
				buttons: Ext.Msg.YESNO,
				icon: Ext.Msg.QUESTION,
				fn: function(g) {
					if (g == "yes") {
						e.getProxy().extraParams.resourceID = "LinkageController.save";
						e.save({
							success: function(h) {
								c.close();
								if (typeof(Ext.getCmp("linkageinformationpanel")) != "undefined") {
									SO.model.LinkageModel.getProxy().extraParams.resourceID = "LinkageController.getLinkage";
									SO.model.LinkageModel.load(h.data.currentShopOrderKey, {
										scope: this,
										success: function(j, i) {
											if (j) {
												Ext.getCmp("linkageinformationpanel").setVisible(true);
												Ext.getCmp("linkageinfoform").loadRecord(j)
											} else {
												Ext.getCmp("linkageinformationpanel").setVisible(false)
											}
										}
									})
								}
							},
							failure: function() {
								Ext.CustomMessageBox.msg("shoporderinformation", bundle.getMsg("socontrol.release.status"), bundle.getMsg("socontrol.message.notSaved"));
								c.close()
							}
						})
					}
				}
			})
		}
	},
	doFilter: function() {
		var d = Ext.getCmp("shoporderselectionwindow"),
			b = Ext.getStore("ShopOrderSelectionStore"),
			a = Ext.ComponentQuery.query("shoporderselectionwindow textfield");
		b.proxy.extraParams.fromKey = d.fromKey;
		b.proxy.extraParams.shopOrderNumber = a[0].getValue();
		b.proxy.extraParams.partNumber = a[1].getValue();
		b.proxy.extraParams.panelQuantity = d.panelQuantity;
		b.load();
		var c = Ext.getCmp("soselectiongrid");
		c.reconfigure(b)
	},
	doClear: function() {
		var a = Ext.ComponentQuery.query("textfield");
		for (var b = 0; b < a.length; b++) {
			if (a[b].idProperty != null) {
				a[b].setValue("")
			}
		}
		this.doFilter()
	},
	onDisplayGeneric: function(c) {
		scope: this;
		var a = this.getShopOrderInfo().getRecord();
		Ext.widget("genericattributeswindow").show();
		var b = Ext.getStore("GenericAttributeStore");
		b.proxy.extraParams.shopOrderKey = a.internalId;
		b.loadPage(1)
	},
	removeFromHold: function(b) {
		b.setDisabled(false);
		var a = this.getShopOrderInfo().getRecord();
		Ext.Msg.show({
			title: bundle.getMsg("socontrol.confirm"),
			msg: bundle.getMsg("socontrol.message.removeFromHold"),
			buttons: Ext.Msg.YESNO,
			icon: Ext.Msg.QUESTION,
			fn: function(c) {
				if (c == "yes") {
					if (a.data.isOnHold == true) {
						Ext.Ajax.request({
							method: "POST",
							format: "json",
							url: window.windowSOContext.ajaxURL,
							params: {
								resourceID: "ShopOrderController.getRemoveFromHold",
								id: a.internalId
							},
							success: function(d) {
								Ext.CustomMessageBox.msg("shoporderinformation", bundle.getMsg("socontrol.release.status"), bundle.getMsg("socontrol.message.removeFromHoldSuccess"));
								b.setDisabled(true)
							},
							failure: function(d) {
								failureHandler(d, "shoporderinformation")
							}
						})
					}
				}
			}
		})
	},
	onBomInformation: function() {
		var b = Ext.getCmp("serialnumbergrid");
		var c = b.getSelectionModel().getSelection();
		this.snrecord = c[0];
		var a = this.getShopOrderInfo().getRecord();
		this.application.controllers.get("ShopOrderController").pushScreen("recipedisplay", {
			viewOnly: !checkPermission("shopOrder.shopOrderBrowser.bomInformation")
		});
		this.application.fireEvent("onShopOrderBom", a)
	},
	onCompleteAppendSerialTree: function(a) {
		if (this.snrecord) {
			var c = a.getStore().getRootNode();
			var b = c.findChild("id", this.snrecord.internalId, true);
			Ext.getCmp("bomtabpanel").setActiveTab("serialtree");
			if (b) {
				a.getSelectionModel().select(b)
			}
			this.snrecord = null
		}
	},
	onAuxiliaryRelease: function() {
		var a = this.getShopOrderInfo().getRecord();
		Ext.Ajax.request({
			scope: this,
			url: window.windowSOContext.ajaxURL,
			method: "GET",
			format: "json",
			params: {
				id: a.internalId,
				resourceID: "ShopOrderController.findShopOrder"
			},
			success: function(b) {
				var c = Ext.create("SO.model.ShopOrderModel"),
					e = Ext.decode(b.responseText).data,
					d = Ext.create("Common.model.PartNumberModel");
				d.set(e.partNumber);
				delete e.partNumber;
				c.set(e);
				c.set("partNumber", d.data);
				this.application.fireEvent("onShopOrderReleaseClick", c, true)
			}
		})
	},
	onFinishAuxiliaryRelease: function() {
		this.onShopOrderInfo(this.getShopOrderInfo().getRecord())
	},
	onDeleteUnstarted: function(c) {
		var d = this;
		var a = this.getShopOrderInfo().getRecord();
		var e = Ext.String.format(bundle.getMsg("socontrol.list.confirmDeleteUnstartedUnits"), a.data.shopOrderNumber);
		var b = false;
		Ext.Msg.show({
			title: bundle.getMsg("socontrol.confirm"),
			msg: e,
			buttons: Ext.Msg.YESNO,
			icon: Ext.Msg.QUESTION,
			fn: function(f) {
				if (f == "yes") {
					if (!a.data.isBatchRelease && !a.data.isOracle && a.data.increasedQuantity > 0) {
						Ext.Msg.show({
							title: bundle.getMsg("socontrol.confirm"),
							width: "500",
							msg: Ext.String.format(bundle.getMsg("socontrol.list.decrementPanelQuantity"), a.data.shopOrderNumber),
							buttons: Ext.Msg.YESNO,
							icon: Ext.Msg.QUESTION,
							scope: this,
							fn: function(g) {
								d.doAjax(a, g == "yes", c)
							}
						})
					} else {
						d.doAjax(a, false, c)
					}
				}
			}
		})
	},
	doAjax: function(a, e, b) {
		scope: this;
		var d = this;
		var c = Ext.getCmp("shoporderinformation");
		c.getEl().mask("Deleting Unstarted Units ..");
		Ext.Ajax.request({
			url: window.windowSOContext.ajaxURL,
			method: "POST",
			params: {
				shopOrderId: a.internalId,
				decreaseQuantity: e,
				resourceID: "SerialNumberController.deleteUnstartedUnits"
			},
			success: function(f) {
				c.unmask();
				var h = Ext.decode(f.responseText);
				var i = h.warning;
				if (i != undefined) {
					Ext.CustomMessageBox.msg("shoporderinformation", bundle.getMsg("socontrol.message.warning"), i)
				}
				if (h.success) {
					var g = h.exportableList;
					scope: this;
					b.setDisabled(true);
					d.onShopOrderInfo(a);
					Ext.CustomMessageBox.msg("shoporderinformation", bundle.getMsg("socontrol.message.information"), "Unstarted Units successfully deleted");
					Ext.Msg.show({
						title: bundle.getMsg("socontrol.confirm"),
						width: "500",
						msg: bundle.getMsg("socontrol.list.generateLog"),
						buttons: Ext.Msg.YESNO,
						icon: Ext.Msg.QUESTION,
						scope: this,
						fn: function(j) {
							if (j == "yes") {
								getResourceFile({
									resourceID: "SerialNumberController.generateDeletedUnitsLog",
									shopOrderNumber: a.get("shopOrderNumber"),
									partNumber: a.get("partNumber"),
									exportableList: Ext.encode(g)
								}, "shoporderinformation", null)
							}
						}
					})
				}
			},
			failure: function(f, g) {
				c.unmask();
				failureHandler(f, c.id)
			}
		})
	},
	onUpdateLinkage: function(c) {
		scope: this;
		var a = this.getShopOrderInfo().getRecord();
		if (a == undefined) {
			return
		}
		Ext.widget("shoporderselectionwindow", {
			panelQuantity: a.data.numberOfPanels,
			fromKey: a.internalId
		}).show();
		var b = Ext.getStore("ShopOrderSelectionStore");
		b.proxy.extraParams.shopOrderNumber = "";
		b.proxy.extraParams.partNumber = "";
		b.proxy.extraParams.panelQuantity = a.data.numberOfPanels;
		b.proxy.extraParams.fromKey = a.internalId;
		b.proxy.extraParams.resourceID = "GenericFetchController.getShopOrdersToLink";
		b.load();
		var d = Ext.getCmp("soselectiongrid");
		d.reconfigure(b)
	},
	onRemoveLinkage: function() {
		scope: this;
		var a = this.getShopOrderInfo().getRecord();
		var b = Ext.create("SO.model.LinkageModel");
		b.set("currentShopOrderKey", a.internalId);
		b.set("nextShopOrderKey", 0);
		b.getProxy().extraParams.isUpdate = false;
		Ext.Msg.show({
			title: bundle.getMsg("socontrol.confirm"),
			msg: bundle.getMsg("socontrol.message.link.removeLink"),
			buttons: Ext.Msg.YESNO,
			icon: Ext.Msg.QUESTION,
			fn: function(c) {
				if (c == "yes") {
					b.getProxy().extraParams.resourceID = "LinkageController.save";
					b.save({
						success: function(d) {
							Ext.CustomMessageBox.msg("shoporderinformation", bundle.getMsg("socontrol.release.status"), bundle.getMsg("socontrol.message.recordRemoved"));
							if (d) {
								if (d.data.nextShopOrderKey == 0) {
									Ext.getCmp("linkageinformationpanel").setVisible(false)
								}
							}
						},
						failure: function() {
							Ext.CustomMessageBox.msg("shoporderinformation", bundle.getMsg("socontrol.release.status"), bundle.getMsg("socontrol.message.changeFailure"))
						}
					})
				}
			}
		})
	},
	onSaveWindow: function(b) {
		scope: this;
		var c = Ext.getCmp("releaseinfo").getForm();
		if (c.isValid()) {
			if (c.getValues().notes != c.getRecord().data.notes) {
				c.getRecord().set({
					notes: c.getValues().notes
				});
				var a = c.getRecord();
				var d = Ext.getStore("HistoryNotesStore");
				d.getProxy().extraParams.resourceID = "ReleaseNotesController.save";
				d.add(a);
				d.sync({
					callback: function() {
						d.getProxy().extraParams.resourceID = "ReleaseNotesController.findAllReleaseNotes";
						d.load()
					}
				})
			}
		}
	},
	onResetWindow: function(a) {
		var b = Ext.getCmp("releaseinfo").getForm();
		b.loadRecord(b.getRecord())
	},
	onHistoryClick: function(a) {
		scope: this;
		Ext.widget("releasenoteshistorywindow").show();
		var c = Ext.getStore("HistoryNotesStore");
		var b = Ext.getCmp("historygrid");
		b.reconfigure(c);
		if (c.count() > 0) {
			b.getSelectionModel().select(0)
		}
	},
	onShopOrderInfo: function(b) {
		var a = Ext.getCmp("xmain");
		a.getEl().mask("Loading...");
		SO.model.ShopOrderInformationModel.load(b.internalId, {
			scope: this,
			success: function(g, d) {
				Ext.getCmp("btnRemoveFromHold").setDisabled(!g.data.isOnHold);
				Ext.getCmp("btnDeleteUnstarted").setDisabled(!g.data.canDeleteUnstartedUnits);
				this.getShopOrderInfo().loadRecord(g);
				var c = Ext.getCmp("oracleinformationpanel"),
					j = Ext.getCmp("mappinginformationpanel");
				if (g.data.isOracle) {
					c.setVisible(true);
					var f = Ext.getCmp("oracleinfogrid");
					f.reconfigure(g.operationSequencesStore);
					if (g.mappingsStore.count() > 0) {
						j.setVisible(true);
						var f = Ext.getCmp("mappinginfogrid");
						g.mappingsStore.sort("mapOpSeq", "ASC");
						f.reconfigure(g.mappingsStore)
					} else {
						j.setVisible(false)
					}
				} else {
					c.setVisible(false);
					j.setVisible(false)
				}
				var i = Ext.getStore("HistoryNotesStore");
				i.getProxy().extraParams.shopOrderKey = b.internalId;
				i.on({
					load: function(m, l, p, n) {
						var o = Ext.getCmp("releaseinfo");
						if (l) {
							if (l.length > 0) {
								o.loadRecord(l[0])
							} else {
								var k = Ext.create("SO.model.ReleaseNotes");
								k.set("shopOrderKey", b.internalId);
								k.set("notes", "");
								k.set("createUser", "");
								k.set("createDttm", "");
								o.loadRecord(k)
							}
						}
					}
				});
				i.load();
				var h = Ext.getCmp("locationinformationpanel");
				if (g.locationsStore.count() > 0) {
					var f = Ext.getCmp("locationinfogrid");
					f.reconfigure(g.locationsStore);
					h.setVisible(true)
				} else {
					h.setVisible(false)
				}
				this.loadSerialNumbers(b, g);
				var e = Ext.getCmp("linkageinformationpanel");
				SO.model.LinkageModel.getProxy().extraParams.resourceID = "LinkageController.getLinkage";
				SO.model.LinkageModel.load(b.internalId, {
					scope: this,
					success: function(m, k) {
						if (m) {
							var l = Ext.getCmp("linkageinfoform");
							l.loadRecord(m);
							e.setVisible(true)
						} else {
							e.setVisible(false)
						}
					}
				});
				a.getEl().unmask()
			},
			failure: function(d, c) {
				a.getEl().unmask();
				Ext.CustomMessageBox.msg("shoporderinformation", bundle.getMsg("socontrol.browser.view.shopOrderInfo"), bundle.getMsg("socontrol.information.idNotFound"))
			}
		})
	},
	loadSerialNumbers: function(a, c) {
		var e = Ext.getCmp("serialinformationpanel"),
			b = Ext.getCmp("serialnumbergrid"),
			d = b.getStore();
		d.proxy.extraParams.shopOrderId = a.internalId;
		d.proxy.extraParams.resourceID = "SerialNumberController.getFindAllSerialNumberView";
		d.proxy.extraParams.ignoreLimit = false;
		d.on({
			load: function(i, h, k, j) {
				if (h) {
					if (h.length == 0) {
						e.setVisible(false)
					} else {
						var g = Ext.getCmp("btnAuxRelease");
						if (g) {
							var f = "R" == c.data.shopOrderStatus;
							isStandard = !c.data.isOracle;
							nonBatchRelease = !c.data.isBatchRelease;
							g.setDisabled(!(f && isStandard && nonBatchRelease))
						}
						e.setVisible(true)
					}
				}
			}
		});
		d.loadPage(1)
	},
	onCloseWindow: function() {
		this.application.controllers.get("ShopOrderController").pushScreen("shoporderbrowserlist")
	},
	printUnitStatusDetails: function() {
		var a = this.getShopOrderInfo().getRecord();
		if (a) {
			var b = "shoporderinformation";
			var d = "GenerateReportController.generateUnitStatusDetails";
			var c = {
				resourceID: d,
				shopOrderId: a.internalId,
				shopOrderNumber: a.get("shopOrderNumber"),
				partNumber: a.get("partNumber"),
				qty: a.get("numberOfPanels")
			};
			getResourceFile(c, b, null)
		}
	},
	onPrintTravelerFromList: function() {
		this.printTravelerFromList(false)
	},
	onReprintTravelerFromList: function() {
		this.printTravelerFromList(true)
	},
	printTravelerFromList: function(d) {
		var b = Ext.getCmp("printtravelerlist");
		var c = b.getSelectionModel().getSelection();
		var a = c[0];
		if (a) {
			if (a.get("oneTravelerPerOrder") == true) {
				this.printOneTravelerPerOrder(a, d)
			} else {
				this.openSelectSerialNumberDialog(a, d)
			}
		}
	},
	printOneTravelerPerOrder: function(a, f) {
		var b = "printtravelerlist";
		var e = "GenerateReportController.generateOneTravelerPerOrder";
		var d = {
			resourceID: e,
			shopOrder: Ext.JSON.encode(a.data),
			partNumber: a.getPartNumber().get("partNumber"),
			partNumberDescription: a.getPartNumber().get("description"),
			isReprint: f,
			isRelease: false
		};
		var c = null;
		if (!f) {
			c = function() {
				var g = Ext.ComponentQuery.query("printtravelerlist button[id=filter]");
				g[0].fireEvent("click", g[0])
			}
		}
		getResourceFile(d, b, c)
	},
	printWipOrOneTravelerPerUnit: function() {
		var a = Ext.getCmp("printtravelerlist");
		var i = a.getSelectionModel().getSelection();
		var b = i[0];
		var a = Ext.getCmp("selectSerialGrid");
		var e = a.getSelectionModel().getSelection().map(function(l) {
			return l.data
		});
		var k = "printtravelerlist";
		var j = "GenerateReportController.generateWipOrOneTravelerPerUnit";
		var f = Ext.getStore("SerialNumberStore");
		var d = f.proxy.extraParams.isReprint;
		var c = {
			resourceID: j,
			shopOrder: Ext.JSON.encode(b.data),
			partNumber: b.getPartNumber().get("partNumber"),
			partNumberDescription: b.getPartNumber().get("description"),
			serialNumberList: Ext.JSON.encode(e),
			isReprint: d,
			isRelease: false,
			portletVersion: typeof(portletVersion) != "undefined" ? portletVersion : "1.0.0"
		};
		var g = null;
		if (!d) {
			g = function() {
				var l = Ext.ComponentQuery.query("printtravelerlist button[id=filter]");
				l[0].fireEvent("click", l[0])
			}
		}
		var h = Ext.getCmp("selectserialnumberwindow");
		h.close();
		getResourceFile(c, k, g)
	},
	openSelectSerialNumberDialog: function(c, d) {
		var e = Ext.widget("selectserialnumberwindow");
		var b = Ext.getCmp("selectSerialGrid");
		Ext.getStore("SerialNumberStore").removeAll();
		var a = Ext.getStore("SerialNumberStore");
		a.proxy.extraParams.shopOrderId = c.getId();
		a.proxy.extraParams.isReprint = d;
		a.proxy.extraParams.resourceID = "SerialNumberController.getSerialNumbersToPrintTraveler";
		a.load();
		b.reconfigure(a);
		e.show()
	},
	onSelectCancel: function() {
		Ext.getCmp("selectserialnumberwindow").close()
	},
	findSNToSelect: function(b) {
		var a = Ext.getCmp("selectSerialGrid").store;
		b = Ext.util.Format.uppercase(b);
		a.filter("serialNumber", new RegExp(".*" + Ext.String.trim(b) + ".*"));
		a.clearFilter(true)
	},
	onSelectClear: function() {
		var a = Ext.getCmp("findSNToSelect");
		a.setValue("");
		this.findSNToSelect(a.getValue())
	},
	onPrintLabel: function() {
		var c = Ext.getCmp("printlabelswindow"),
			e = Ext.getCmp("printlabelsform").getForm();
		if (e.isValid()) {
			var b = Ext.ComponentQuery.query("#printallsns"),
				d = null;
			if (b[0].getValue()) {
				if (c.sn_data) {
					d = Ext.encode(Ext.Array.pluck(c.sn_data, "serialNumber"));
					this.doPrintLabels(e, d)
				} else {
					var a = Ext.create("SO.store.SerialNumberStore");
					a.proxy.extraParams.shopOrderId = c.shopOrderId;
					a.proxy.extraParams.resourceID = "SerialNumberController.getFindAllSerialNumberView";
					a.proxy.extraParams.ignoreLimit = true;
					a.load({
						scope: this,
						callback: function() {
							d = Ext.encode(Ext.Array.pluck(Ext.Array.pluck(a.data.items, "data"), "serialNumber"));
							this.doPrintLabels(e, d)
						}
					})
				}
			} else {
				var f = Ext.ComponentQuery.query("#serialNumberHiddenList");
				if (f[0].getValue() == null || f[0].getValue() == "") {
					Ext.CustomMessageBox.msg("printlabelswindow", bundle.getMsg("socontrol.message.error"), bundle.getMsg("socontrol.print.selectSerialNumber"));
					return
				}
				d = f[0].getValue();
				this.doPrintLabels(e, d)
			}
		}
	},
	doPrintLabels: function(b, g) {
		var d = Ext.getCmp("printlabelswindow");
		var c = b.getFieldValues();
		if (!c.downloadLabel) {
			var e = {
				resourceID: "LabelController.printLabel",
				formValues: Ext.JSON.encode(c),
				serialNumberList: g,
				partKey: d.partKey,
				printDest: "que"
			};
			d.getEl().mask("Loading...");
			Ext.Ajax.request({
				scope: this,
				url: window.windowSOContext.ajaxURL,
				params: e,
				success: function(j) {
					var k = Ext.decode(j.responseText);
					if (k.print_label_msg) {
						Ext.CustomMessageBox.msg("shoporderinformation", bundle.getMsg("socontrol.browser.labelPrintMessage"), k.print_label_msg)
					}
					d.getEl().unmask();
					d.close()
				}
			})
		} else {
			d.getEl().mask("Loading...");
			var a = Ext.getCmp("labelType"),
				h = a.findRecordByValue(a.getValue());
			list = Ext.JSON.decode(g);
			pathFile = [];
			list.forEach(function(k, j) {
				pathFile.push(path_download_file + h.get("a1") + "_" + k + ".pdf")
			});
			c.printerQueue = "file";
			var f = "shopOrderNumber_" + d.shopOrderNumber;
			var e = {
				resourceID: "LabelController.printAndDownloadLabel",
				formValues: Ext.JSON.encode(c),
				serialNumberList: g,
				partKey: d.partKey,
				printDest: "key",
				pathFile: Ext.JSON.encode(pathFile),
				isDownload: true,
				titleFile: f
			};
			var i = function() {
					var j = Ext.getCmp("printlabelswindow");
					j.getEl().unmask();
					j.close()
				};
			if (Ext.JSON.decode(g).length > 5) {
				e.isDownload = false;
				Ext.Ajax.request({
					scope: this,
					url: window.windowSOContext.ajaxURL,
					method: "POST",
					params: e,
					success: function(j) {
						var k = Ext.decode(j.responseText);
						var l = {
							resourceID: "LabelController.downloadLabel",
							isDownload: true,
							pathFile: Ext.JSON.encode([k.absolutePathFile]),
							titleFile: f
						};
						this.onPrintFile(l, i, d)
					},
					failure: function(j) {
						failureHandler(j, "printlabelswindow");
						d.getEl().unmask()
					}
				})
			} else {
				this.onPrintFile(e, i, d)
			}
		}
	},
	onSelectPrintLabelCancel: function() {
		Ext.getCmp("printlabelselectserialnbrs").close()
	},
	findSNByTypeAddToSelect: function(b) {
		var a = Ext.getCmp("results").store;
		a.filter("serialNumber", b);
		a.clearFilter(true)
	},
	findSNAddToSelect: function(c) {
		var a = Ext.getCmp("results").store;
		var e = Ext.getCmp("selected").store;
		var b = a.findExact("serialNumber", c.toUpperCase());
		if (b != -1) {
			var d = a.getAt(b);
			a.remove(d);
			e.add(d);
			Ext.getCmp("findSNToSelect").setValue("")
		}
	},
	onAddMultiple: function() {
		Ext.widget("addmultipleserialnumberswindow", {
			id: "addmultiplefromprintlabel"
		}).show()
	},
	resetFromPrintLabelSelectSN: function() {
		var b = Ext.getCmp("results").store,
			a = Ext.getCmp("selected").store;
		b.add(Ext.getCmp("selected").store.getRange());
		b.sort("serialNumber", "ASC");
		a.removeAll()
	},
	onOkAddMultipleSN: function() {
		var c = Ext.getCmp("addmultiplefromprintlabel").down("textareafield").getRawValue();
		if (c != "") {
			var a = c.split("\n");
			var b;
			for (b = 0; b < a.length; b++) {
				if (a[b] != "") {
					this.findSNAddToSelect(a[b])
				}
			}
			Ext.getCmp("addmultiplefromprintlabel").close()
		}
	},
	onCancelAddMultipleSN: function() {
		Ext.getCmp("addmultiplefromprintlabel").close()
	},
	onSavePrintLabelSelectSN: function() {
		var c = Ext.getCmp("selected").getStore();
		if (c.getCount() > 0) {
			var a = Ext.ComponentQuery.query("#selectsns");
			a[0].setBoxLabel(bundle.getMsg("socontrol.release.print.selectSerialNumbers") + " (" + bundle.getMsg("socontrol.quantityTable") + ": " + c.getCount() + ")");
			var b = Ext.ComponentQuery.query("#serialNumberHiddenList");
			b[0].setValue(Ext.encode(Ext.Array.pluck(Ext.Array.pluck(c.data.items, "data"), "serialNumber")));
			Ext.getCmp("printlabelselectserialnbrs").close()
		} else {
			Ext.CustomMessageBox.msg("printlabelselectserialnbrs", bundle.getMsg("socontrol.message.error"), bundle.getMsg("socontrol.print.selectSerialNumber"))
		}
	}
});
Ext.define("SO.view.util.AddMultipleSerialNumbersWindow", {
	extend: Ext.window.Window,
	alias: "widget.addmultipleserialnumberswindow",
	width: 450,
	height: 350,
	id: "addmultipleserialnumberswindow",
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("socontrol.addSerialNumber");
		a.border = 0;
		a.modal = true;
		a.constrain = true;
		resizable: false;
		a.renderTo = "xmain";
		a.items = a.buildItems();
		a.dockedItems = a.buildDockedItems();
		this.callParent(arguments)
	},
	buildItems: function() {
		var a = [{
			xtype: "textareafield",
			fieldLabel: bundle.getMsg("socontrol.enterMultipleSN"),
			labelAlign: "top",
			style: {
				marginTop: "5px",
				marginBottom: "5px"
			},
			width: 450,
			height: 350,
			id: "multipleSnArea",
			autoScroll: true
		}];
		return a
	},
	buildDockedItems: function() {
		var a = {
			xtype: "toolbar",
			dock: "bottom",
			items: ["->",
			{
				xtype: "button",
				text: bundle.getMsg("socontrol.ok"),
				action: "onOkAddMultipleSN"
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.cancel"),
				action: "onCancelAddMultipleSN"
			}]
		};
		return a
	}
});
Ext.define("SO.model.ShopOrderMaintenanceModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "id"
	}, {
		name: "shopOrderNumber"
	}, {
		name: "orderType"
	}, {
		name: "partNumber"
	}, {
		name: "quantity"
	}, {
		name: "revision"
	}, {
		name: "shopOrderStatus"
	}, {
		name: "oracleShopOrder"
	}, {
		name: "allowAddOperation"
	}, {
		name: "allowRemoveOperation"
	}, {
		name: "boardsPerPanel"
	}, {
		name: "dueDate"
	}],
	validations: [{
		type: "presence",
		field: "ShopOrderNumber"
	}, {
		type: "presence",
		field: "partNumber"
	}, {
		type: "presence",
		field: "quantity"
	}, {
		type: "exclusion",
		field: "quantity",
		list: ["0"]
	}, {
		type: "presence",
		field: "quantity",
		matcher: "^d+$"
	}, {
		type: "presence",
		field: "revision"
	}],
	idProperty: "id"
});
Ext.define("SO.model.SerialNumberMaintenanceFilterModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "soNumberField"
	}, {
		name: "pNumberField"
	}, {
		name: "revField"
	}, {
		name: "opTypeField"
	}, {
		name: "soTypeField"
	}, {
		name: "soStatusListField"
	}]
});
Ext.define("SO.view.util.RemoveMultipleSerialNumbersWindow", {
	extend: Ext.window.Window,
	alias: "widget.removemultipleserialnumberswindow",
	width: 450,
	height: 350,
	id: "removemultipleserialnumberswindow",
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("socontrol.removeSerialNumber");
		a.border = 0;
		a.modal = true;
		a.constrain = true;
		a.renderTo = "xmain";
		resizable: false;
		a.items = a.buildItems();
		a.dockedItems = a.buildDockedItems();
		this.callParent(arguments)
	},
	buildItems: function() {
		var a = [{
			xtype: "textareafield",
			fieldLabel: bundle.getMsg("socontrol.enterMultipleSN"),
			labelAlign: "top",
			style: {
				marginTop: "5px",
				marginBottom: "5px"
			},
			width: 450,
			height: 350,
			autoScroll: true,
			id: "multipleSnArea"
		}];
		return a
	},
	buildDockedItems: function() {
		var a = {
			xtype: "toolbar",
			dock: "bottom",
			items: ["->",
			{
				xtype: "button",
				text: bundle.getMsg("socontrol.ok"),
				action: "onOkRemoveMultipleSN"
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.cancel"),
				action: "onCancelRemoveMultipleSN"
			}]
		};
		return a
	}
});
Ext.define("SO.view.SerialNumberMaintenance.SerialNumberMaintenanceFilter", {
	extend: Ext.panel.Panel,
	alias: "widget.serialnumbermaintenancefilter",
	height: "100%",
	width: "100%",
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("socontrol.maintenanceTitle");
		a.store = Ext.getStore("SerialNumberMaintenanceStore");
		a.border = 0;
		a.items = a.buildPanel();
		this.callParent(arguments)
	},
	listeners: {
		afterrender: function() {
			Ext.getCmp("soNumberField").focus()
		}
	},
	buildPanel: function() {
		var a = [{
			xtype: "container",
			layout: {
				type: "vbox",
				align: "stretch"
			},
			width: "100%",
			border: 0,
			items: [{
				xtype: "panel",
				layout: {
					type: "column"
				},
				border: 0,
				style: {
					padding: "10px",
					marginRight: "0px"
				},
				items: [{
					xtype: "panel",
					border: 0,
					baseCls: "float_right_panel",
					items: [{
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.soNumber"),
						labelAlign: "top",
						name: "soNumberField",
						idProperty: "soNumberField",
						id: "soNumberField",
						value: "",
						width: 130,
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.partNumber"),
						labelAlign: "top",
						name: "pNumberField",
						idProperty: "pNumberField",
						value: "",
						width: 130,
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.revisionTable"),
						labelAlign: "top",
						name: "revField",
						width: 130,
						idProperty: "revField",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "combobox",
						fieldLabel: bundle.getMsg("socontrol.soType"),
						labelAlign: "top",
						name: "soTypeField",
						idProperty: "soTypeField",
						valueField: "id",
						displayField: "soTypeDescription",
						value: 3,
						width: 130,
						cls: "comboFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "comboFilterCss",
						editable: false,
						store: new Ext.data.ArrayStore({
							fields: ["id", "soTypeDescription"],
							listeners: {
								load: function(b) {
									b.sort("soTypeDescription", "ASC")
								}
							},
							data: [
								[1, bundle.getMsg("socontrol.soOracle")],
								[2, bundle.getMsg("socontrol.soStandard")],
								[3, bundle.getMsg("socontrol.all")]
							]
						})
					}, {
						xtype: "panel",
						layout: {
							type: "vbox"
						},
						id: "painelButtons",
						baseCls: "float_right_panel",
						style: {
							marginLeft: "15px"
						},
						border: 0,
						items: [{
							xtype: "hiddenfield",
							name: "soFilteredHidden",
							id: "soFilteredHidden",
							idProperty: "soFilteredHidden",
							value: ""
						}, {
							xtype: "button",
							id: "filter",
							text: bundle.getMsg("socontrol.filter"),
							action: this.assignScreen ? "assignmentFilter" : "maintenanceFilter",
							iconCls: "filterButtonIcon"
						}, {
							xtype: "tbspacer",
							height: 5
						}, {
							xtype: "button",
							id: "clear",
							text: bundle.getMsg("socontrol.clear"),
							action: this.assignScreen ? "assignmentClear" : "maintenanceClear",
							iconCls: "clearButtonIcon"
						}]
					}]
				}]
			}]
		}];
		return a
	}
});
Ext.define("SO.view.SerialNumberMaintenance.SerialNumberMaintenanceList", {
	extend: Ext.grid.Panel,
	alias: "widget.serialnumbermaintenancelist",
	id: "serialnumbermaintenancelist",
	autoWidth: true,
	autoHeight: true,
	initComponent: function() {
		var a = this;
		a.border = 0;
		a.dockedItems = a.buildFilterTopBar();
		a.stripeRows = false;
		a.store = Ext.getStore("SerialNumberMaintenanceStore");
		a.columns = a.buildColumns();
		a.tbar = a.buildDockedItemsBar();
		a.bbar = a.buildBottomBar();
		a.selModel = Ext.create("Ext.selection.CheckboxModel", {
			mode: "SINGLE",
			showHeaderCheckbox: false,
			listeners: {
				selectionchange: function(g, e) {
					var f = Ext.getCmp("addToolbar");
					var c = Ext.getCmp("removeToolbar");
					f.setDisabled(true);
					c.setDisabled(true);
					var d = e[0];
					if (d != null) {
						if (!d.get("statusChecked")) {
							var b = Ext.getCmp("serialnumbermaintenancelist");
							b.getEl().mask("Loading ..");
							Ext.Ajax.request({
								scope: this,
								url: window.windowSOContext.ajaxURL,
								params: {
									resourceID: "ShopOrderController.checkShopOrderStatusToMaint",
									id: d.getId()
								},
								success: function(i) {
									b.getEl().unmask();
									var h = Ext.decode(i.responseText);
									d.set("remainingQuantity", h.remainingQuantity);
									d.set("removableQuantity", h.removableQuantity);
									d.set("hasNonSerBatch", h.hasNonSerBatch);
									d.set("statusChecked", true);
									f.setDisabled(d.get("hasNonSerBatch") || !d.get("remainingQuantity") || d.get("remainingQuantity") < 1);
									c.setDisabled(!d.get("removableQuantity") || d.get("removableQuantity") < 1)
								},
								failure: function(h) {
									b.getEl().unmask();
									failureHandler(h, b.id)
								}
							})
						} else {
							f.setDisabled(d.get("hasNonSerBatch") || !d.get("remainingQuantity") || d.get("remainingQuantity") < 1);
							c.setDisabled(!d.get("removableQuantity") || d.get("removableQuantity") < 1)
						}
					}
				}
			}
		});
		a.on({
			afterrender: function() {
				checkPermissionsByContainer(a)
			}
		});
		a.callParent(arguments)
	},
	buildDockedItemsBar: function() {
		var a;
		a = Ext.create("Ext.toolbar.Toolbar", {
			items: [{
				icon: path + "resources/images/16X16/add.png",
				text: bundle.getMsg("socontrol.add"),
				id: "addToolbar",
				action: "onOpenAddPanelFromList",
				actionKey: "shopOrder.serialNumberMaintenance.addSerialNumber",
				scope: this,
				disabled: true
			}, {
				icon: path + "resources/images/16X16/remove.png",
				text: bundle.getMsg("socontrol.remove"),
				id: "removeToolbar",
				action: "onOpenRemovePanelFromList",
				actionKey: "shopOrder.serialNumberMaintenance.removeSerialNumber",
				scope: this,
				disabled: true
			}, "->",
			{
				icon: path + "resources/images/16X16/print.png",
				tooltip: bundle.getMsg("socontrol.printExportFiltered"),
				scope: this,
				action: "printFiltered",
				actionKey: "shopOrder.shopOrderBrowser.printExportFilteredShopOrderBrowser",
				id: "serialNumberMaintenancePrintTop"
			}]
		});
		return a
	},
	buildColumns: function() {
		var a = [];
		a = [{
			header: bundle.getMsg("socontrol.soNumber"),
			width: 120,
			flex: 1,
			sortable: true,
			dataIndex: "shopOrderNumber"
		}, {
			header: bundle.getMsg("socontrol.partNumber"),
			flex: 1,
			sortable: true,
			width: 140,
			dataIndex: "partNumberDataIndex"
		}, {
			header: bundle.getMsg("socontrol.status"),
			flex: 1,
			sortable: true,
			dataIndex: "shopOrderStatus"
		}, {
			header: bundle.getMsg("socontrol.quantityTable"),
			width: 60,
			sortable: true,
			dataIndex: "quantity"
		}, {
			header: bundle.getMsg("socontrol.boardsPerPanelList"),
			width: 60,
			sortable: true,
			dataIndex: "boardsPerPanel"
		}, {
			header: bundle.getMsg("socontrol.revisionTable"),
			width: 60,
			sortable: true,
			dataIndex: "revision"
		}, {
			header: bundle.getMsg("socontrol.startDate"),
			width: 110,
			sortable: true,
			dataIndex: "startDate"
		}, {
			header: bundle.getMsg("socontrol.completionDate"),
			flex: 1,
			dataIndex: "dueDate",
			sortable: true
		}];
		return a
	},
	buildFilterTopBar: function() {
		var a;
		a = Ext.create("SO.view.SerialNumberMaintenance.SerialNumberMaintenanceFilter");
		return a
	},
	buildBottomBar: function() {
		var a;
		a = Ext.create("Ext.Custom.CustomPaging", {
			border: 0,
			store: Ext.getStore("SerialNumberMaintenanceStore"),
			displayInfo: false,
			beforePageText: bundle.getMsg("socontrol.page"),
			afterPageText: ""
		});
		a.add("->");
		a.add({
			icon: path + "resources/images/16X16/print.png",
			tooltip: bundle.getMsg("socontrol.printExportFiltered"),
			scope: this,
			action: "printFiltered",
			actionKey: "shopOrder.shopOrderBrowser.printExportFilteredShopOrderBrowser",
			id: "serialNumberMaintenancePrintBottom"
		});
		a.doLayout();
		return a
	}
});
Ext.define("SO.view.util.RemoveSerialNumberWindow", {
	extend: Ext.window.Window,
	alias: "widget.removeserialnumberwindow",
	width: 874,
	height: 558,
	id: "removeserialnumberwindow",
	modal: true,
	constrain: true,
	renderTo: "xmain",
	resizable: false,
	hasNonSerBatch: false,
	initComponent: function() {
		var a = this;
		a.items = a.buildPanel();
		a.title = bundle.getMsg("socontrol.removeSerialNumber");
		a.border = 0;
		a.layout = {
			type: "hbox",
			align: "center"
		};
		this.callParent(arguments)
	},
	buildPanel: function() {
		var a = Ext.create("Ext.grid.Panel", {
			style: {
				marginTop: "10px",
				marginLeft: "6px"
			},
			id: "removable",
			multiSelect: true,
			viewConfig: {
				plugins: {
					ptype: "gridviewdragdrop",
					dragGroup: "firstGridDDGroup",
					dropGroup: "secondGridDDGroup"
				},
				listeners: {
					beforedrop: function(g, i, h, f) {
						Ext.getCmp("selected").getSelectionModel().selected.items[0].store.rejectChanges()
					}
				}
			},
			columns: [{
				header: bundle.getMsg("socontrol.serialNumber"),
				width: 110,
				flex: 1,
				sortable: true,
				dataIndex: "serialNumber"
			}, {
				header: bundle.getMsg("socontrol.unitStatusKey"),
				width: 50,
				sortable: true,
				dataIndex: "unitStatusKey"
			}, {
				header: bundle.getMsg("socontrol.location"),
				width: 120,
				flex: 1,
				sortable: true,
				dataIndex: "location"
			}, {
				header: bundle.getMsg("socontrol.quantityTable"),
				dataIndex: "quantity",
				width: 75,
				sortable: true,
				hidden: !this.hasNonSerBatch
			}],
			stripeRows: true,
			title: bundle.getMsg("socontrol.removable"),
			margins: "0 2 0 0",
			height: 390,
			width: 420
		});
		var e = Ext.create("Ext.grid.plugin.CellEditing", {
			clicksToEdit: 1
		});
		var b = Ext.create("Ext.grid.Panel", {
			style: {
				marginTop: "10px",
				marginLeft: "10px"
			},
			id: "selected",
			viewConfig: {
				plugins: [{
					ptype: "gridviewdragdrop",
					dragGroup: "secondGridDDGroup",
					dropGroup: "firstGridDDGroup"
				}]
			},
			columns: [{
				header: bundle.getMsg("socontrol.serialNumber"),
				width: 110,
				flex: 1,
				sortable: true,
				dataIndex: "serialNumber"
			}, {
				header: bundle.getMsg("socontrol.unitStatusKey"),
				width: 50,
				sortable: true,
				dataIndex: "unitStatusKey"
			}, {
				header: bundle.getMsg("socontrol.location"),
				width: 120,
				flex: 1,
				sortable: true,
				dataIndex: "location"
			}, {
				header: bundle.getMsg("socontrol.decreaseQuantity"),
				dataIndex: "quantity",
				width: 75,
				sortable: true,
				hidden: !this.hasNonSerBatch,
				editor: {
					xtype: "numberfield",
					allowDecimals: false,
					minValue: 1,
					newProperty: 1
				}
			}],
			plugins: [e],
			stripeRows: true,
			title: bundle.getMsg("socontrol.selected"),
			margins: "0 0 0 3",
			height: 390,
			width: 420,
			listeners: {
				beforeedit: function(h, i, g) {
					if (i.field == "quantity") {
						var f = Ext.getCmp("selected").columns[i.colIdx];
						if (i.record.data.unitType == 8) {
							f.setEditor({
								xtype: "numberfield",
								allowDecimals: false,
								minValue: 1,
								maxValue: i.record.raw.quantity
							})
						}
						if (i.record.data.unitType == 8) {
							return true
						}
					}
					return false
				}
			}
		});
		var c = Ext.create("Ext.form.Panel", {
			style: {
				marginTop: "10px",
				marginLeft: "6px"
			},
			border: 0,
			layout: "column",
			items: [{
				xtype: "customtextfield",
				fieldLabel: bundle.getMsg("socontrol.filter"),
				labelAlign: "top",
				width: 837,
				style: {
					marginBottom: "5px"
				},
				id: "findSNByTypeToSelect",
				enableKeyEvents: true
			}, {
				xtype: "customtextfield",
				fieldLabel: bundle.getMsg("socontrol.scanOrType"),
				labelAlign: "top",
				width: 812,
				id: "findSNToSelect",
				enableKeyEvents: true
			}, {
				xtype: "panel",
				layout: "vbox",
				width: 24,
				border: 0,
				style: {
					marginTop: "19px",
					marginLeft: "2px"
				},
				items: [{
					xtype: "button",
					icon: path + "resources/images/16X16/multipleSNs.png",
					action: "onRemoveMultiple"
				}]
			}]
		});
		var d = Ext.create("Ext.panel.Panel", {
			width: 864,
			height: 532,
			layout: "column",
			defaults: {
				flex: 1
			},
			items: [a, b, c],
			dockedItems: {
				xtype: "toolbar",
				dock: "bottom",
				items: ["->",
				{
					xtype: "button",
					text: bundle.getMsg("socontrol.reset"),
					action: "reset"
				}, {
					xtype: "button",
					text: bundle.getMsg("socontrol.selectAll"),
					handler: function() {
						b.store.loadData(a.store.getRange());
						a.store.removeAll()
					}
				}, {
					xtype: "button",
					text: bundle.getMsg("socontrol.save"),
					action: "onSave"
				}, {
					xtype: "button",
					text: bundle.getMsg("socontrol.cancel"),
					action: "onCancel"
				}]
			}
		});
		return d
	}
});
Ext.define("SO.store.SerialNumberMaintenanceStore", {
	extend: Common.store.PaggingStore,
	model: "SO.model.ShopOrderModel",
	pageSize: 50,
	remoteSort: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "ShopOrderController.getShopOrderMaintenance"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	}
});
Ext.define("SO.controller.SerialNumberMaintenanceController", {
	extend: Ext.app.Controller,
	stores: ["SerialNumberMaintenanceStore", "SerialNumberStore"],
	models: ["ShopOrderMaintenanceModel", "SerialNumberModel", "SerialNumberMaintenanceFilterModel"],
	views: ["SerialNumberMaintenance.SerialNumberMaintenanceList", "SerialNumberMaintenance.SerialNumberMaintenanceFilter", "util.RemoveSerialNumberWindow", "util.RemoveMultipleSerialNumbersWindow", "util.AddSerialNumberWindow", "util.AddMultipleSerialNumbersWindow"],
	remainingQty: 0,
	init: function() {
		this.control({
			"serialnumbermaintenancelist button[action=onOpenAddPanelFromList]": {
				click: this.onOpenAddPanelFromList
			},
			"serialnumbermaintenancelist button[action=onOpenRemovePanelFromList]": {
				click: this.onOpenRemovePanelFromList
			},
			"#removefrommaintenance button[action=onSave]": {
				click: this.onSaveRemove
			},
			"#addfrommaintenance button[action=onSave]": {
				click: this.onSaveAdd
			},
			"#addfrommaintenance button[action=selectAll]": {
				click: this.onSelectAllAddFromMaint
			},
			"#addfrommaintenance grid[id=results]": {
				scope: this,
				itemdblclick: function(g, f, c, a, d, b) {
					toStore = Ext.getCmp("selected").store;
					if (a > -1 && this.remainingQty > toStore.getCount()) {
						this.itemDoubleClick(Ext.getCmp("results").store, Ext.getCmp("selected").store, f)
					}
				}
			},
			"#addfrommaintenance grid[id=selected]": {
				scope: this,
				itemdblclick: function(g, f, c, a, d, b) {
					if (a > -1) {
						this.itemDoubleClick(Ext.getCmp("selected").store, Ext.getCmp("results").store, f)
					}
				}
			},
			"#removefrommaintenance grid[id=removable]": {
				scope: this,
				itemdblclick: function(g, f, c, a, d, b) {
					if (a > -1) {
						this.itemDoubleClick(Ext.getCmp("removable").store, Ext.getCmp("selected").store, f)
					}
				}
			},
			"#removefrommaintenance grid[id=selected]": {
				scope: this,
				itemdblclick: function(g, f, c, a, d, b) {
					if (a > -1) {
						this.itemDoubleClick(Ext.getCmp("selected").store, Ext.getCmp("removable").store, f)
					}
				}
			},
			"#removefrommaintenance button[action=onCancel]": {
				click: this.onRemoveCancel
			},
			"#addfrommaintenance button[action=onCancel]": {
				click: this.onAddCancel
			},
			"#removefrommaintenance button[action=onRemoveMultiple]": {
				click: this.onRemoveMultiple
			},
			"#addfrommaintenance button[action=onAddMultiple]": {
				click: this.onAddMultiple
			},
			"#removefrommaintenance textfield[id=findSNToSelect]": {
				keypress: function(b, a) {
					if (a.getKey() == Ext.EventObject.ENTER && b.value != null && b.value != "") {
						this.findSNRemoveToSelect(b.getValue())
					}
				}
			},
			"#addfrommaintenance textfield[id=findSNToSelect]": {
				keypress: function(b, a) {
					if (a.getKey() == Ext.EventObject.ENTER && b.value != null && b.value != "") {
						this.findSNAddToSelect(b.getValue())
					}
				}
			},
			"#removefrommaintenance textfield[id=findSNByTypeToSelect]": {
				keyup: function(b, a) {
					this.findSNByTypeRemoveToSelect(b.getValue())
				}
			},
			"#addfrommaintenance textfield[id=findSNByTypeToSelect]": {
				keyup: function(b, a) {
					this.findSNByTypeAddToSelect(b.getValue())
				}
			},
			"#removefrommaintenance button[action=reset]": {
				click: this.resetFromRemoveFromMaintenanceScreen
			},
			"#addfrommaintenance button[action=reset]": {
				click: this.resetFromAddFromMaintenanceScreen
			},
			"#removemultiplefrommaintenance button[action=onOkRemoveMultipleSN]": {
				click: this.onOkRemoveMultipleSN
			},
			"#addmultiplefrommaintenance button[action=onOkAddMultipleSN]": {
				click: this.onOkAddMultipleSN
			},
			"#removemultiplefrommaintenance button[action=onCancelRemoveMultipleSN]": {
				click: this.onCancelRemoveMultipleSN
			},
			"#addmultiplefrommaintenance button[action=onCancelAddMultipleSN]": {
				click: this.onCancelAddMultipleSN
			}
		})
	},
	onSelectAllAddFromMaint: function() {
		var a = Ext.getCmp("results");
		if (a == undefined) {
			return
		}
		var b = this.remainingQty - a.store.getCount();
		if (b < 0) {
			Ext.CustomMessageBox.msg("addfrommaintenance", bundle.getMsg("socontrol.message.error"), bundle.getMsg("socontrol.assignment.message.maxNumberToAssign"), this.remainingQty);
			return false
		}
		return true
	},
	resetFromAddFromMaintenanceScreen: function() {
		Ext.getCmp("results").store.load();
		Ext.getCmp("selected").store.removeAll();
		this.changeRemainingQty()
	},
	resetFromRemoveFromMaintenanceScreen: function() {
		Ext.getCmp("removable").store.load();
		Ext.getCmp("selected").store.removeAll()
	},
	findSNByTypeRemoveToSelect: function(c) {
		c = Ext.String.trim(c);
		var a = Ext.getCmp("removable").store;
		a.clearFilter(true);
		var b = new RegExp(".*" + Ext.String.trim(c) + ".*", "i");
		a.filter("serialNumber", b)
	},
	findSNByTypeAddToSelect: function(c) {
		c = Ext.String.trim(c);
		var a = Ext.getCmp("results").store;
		a.clearFilter(true);
		var b = new RegExp(".*" + Ext.String.trim(c) + ".*", "i");
		a.filter("serialNumber", b)
	},
	findSNRemoveToSelect: function(c) {
		var a = Ext.getCmp("removable").store;
		var b = a.findExact("serialNumber", c.toUpperCase());
		if (b != -1) {
			var d = a.getAt(b);
			a.remove(d);
			var e = Ext.getCmp("selected").store;
			e.add(d)
		} else {
			Ext.CustomMessageBox.msg("removefrommaintenance", bundle.getMsg("socontrol.message.error"), Ext.String.format(bundle.getMsg("socontrol.maintenance.message.serialNumberIsNotInRemovableList"), c.toUpperCase()))
		}
		Ext.getCmp("findSNToSelect").setValue("")
	},
	findSNAddToSelect: function(c) {
		var a = Ext.getCmp("results").store;
		var b = a.findExact("serialNumber", c.toUpperCase());
		if (b != -1) {
			var d = a.getAt(b);
			a.remove(d);
			var e = Ext.getCmp("selected").store;
			e.add(d)
		} else {
			Ext.CustomMessageBox.msg("addfrommaintenance", bundle.getMsg("socontrol.message.error"), Ext.String.format(bundle.getMsg("socontrol.maintenance.message.serialNumberIsNotInResultList"), c.toUpperCase()))
		}
		Ext.getCmp("findSNToSelect").setValue("")
	},
	onOpenAddPanelFromList: function() {
		var a = Ext.getCmp("serialnumbermaintenancelist");
		var i = a.getSelectionModel().getSelection();
		var d = i[0];
		if (d) {
			var c = Ext.widget("addserialnumberwindow", {
				id: "addfrommaintenance"
			});
			var f = Ext.getCmp("results");
			var h = Ext.getStore("SerialNumberStore");
			f.reconfigure(h);
			h.proxy.extraParams.partKey = d.get("partId");
			h.proxy.extraParams.resourceID = "SerialNumberController.addAssignSerialNumber";
			h.load();
			this.remainingQty = d.data.remainingQuantity;
			var g = c.title + " - " + bundle.getMsg("socontrol.soNumber") + ": " + d.data.shopOrderNumber + " - " + bundle.getMsg("socontrol.remainingQty") + ": " + this.remainingQty;
			c.setTitle(g);
			if (this.remainingQty <= 0) {
				Ext.getCmp("results").getView().getPlugin("gridviewdragdrop").dragZone.lock()
			} else {
				Ext.getCmp("results").getView().getPlugin("gridviewdragdrop").dragZone.unlock()
			}
			Ext.getCmp("findSNToSelect").focus();
			var b = Ext.getCmp("selected");
			var e = Ext.create("SO.store.SerialNumberStore");
			b.reconfigure(e);
			this.addListenerDataChangedToStore(e);
			c.show()
		}
	},
	onOpenRemovePanelFromList: function() {
		var d = Ext.getCmp("serialnumbermaintenancelist");
		var f = d.getSelectionModel().getSelection();
		var a = f[0];
		if (a) {
			var c = Ext.widget("removeserialnumberwindow", {
				id: "removefrommaintenance",
				hasNonSerBatch: a.get("hasNonSerBatch")
			});
			var g = Ext.getCmp("removable");
			var b = Ext.create("SO.store.SerialNumberStore");
			b.getProxy().extraParams.shopOrderId = a.getId();
			b.getProxy().extraParams.resourceID = "SerialNumberController.findShopOrderUnitsToMaintan";
			b.getProxy().extraParams.serialsToRemove = "true";
			b.load({
				callback: function() {
					var i = c.title + " - " + bundle.getMsg("socontrol.soNumber") + ": " + a.data.shopOrderNumber;
					c.setTitle(i)
				}
			});
			g.reconfigure(b);
			var e = Ext.getCmp("selected");
			var h = Ext.create("SO.store.SerialNumberStore");
			e.reconfigure(h);
			c.show();
			Ext.Function.defer(function() {
				Ext.getCmp("findSNToSelect").focus()
			}, 50)
		}
	},
	onSaveAdd: function() {
		var a = Ext.getCmp("selected").getStore();
		if (a.getCount() <= this.remainingQty) {
			this.doSave("add")
		} else {
			Ext.CustomMessageBox.msg("addfrommaintenance", bundle.getMsg("socontrol.message.error"), bundle.getMsg("socontrol.maintenance.message.toManySerialNumbersWereSelected"))
		}
	},
	onSaveRemove: function() {
		this.doSave("remove")
	},
	doSave: function(e) {
		var f = Ext.getCmp("selected"),
			h = f.getStore();
		if (h.getCount() < 1) {
			var d = "";
			if (e == "remove") {
				d = "removefrommaintenance"
			} else {
				if (e == "add") {
					d = "addfrommaintenance"
				}
			}
			Ext.CustomMessageBox.msg(d, bundle.getMsg("socontrol.message.error"), bundle.getMsg("error.progress.socontrol.serialNumberNotSelected"));
			return
		}
		var a = Ext.getCmp("serialnumbermaintenancelist"),
			j = a.getSelectionModel().getSelection(),
			g = j[0],
			k = "[]",
			b = "[]",
			c = "[]",
			i = null;
		if (e == "remove") {
			if (j[0].get("hasNonSerBatch")) {
				if (f.plugins[0]) {
					f.plugins[0].completeEdit()
				}
				h.filterBy(function(l, m) {
					return l.data.unitType == 8
				});
				c = Ext.encode(Ext.pluck(h.getRange(), "data"));
				h.filterBy(function(l, m) {
					return l.data.unitType != 8
				});
				b = Ext.encode(Ext.pluck(h.getRange(), "data"))
			} else {
				b = Ext.encode(Ext.pluck(h.getRange(), "data"))
			}
			h.filterBy(function(l, m) {
				return true
			});
			i = Ext.getCmp("removefrommaintenance")
		} else {
			if (e == "add") {
				k = Ext.encode(Ext.pluck(h.getRange(), "data"));
				i = Ext.getCmp("addfrommaintenance")
			}
		}
		i.getEl().mask("Saving ...");
		Ext.Ajax.request({
			scope: this,
			url: window.windowSOContext.ajaxURL,
			params: {
				resourceID: "SerialNumberController.saveSerialNumbersForShopOrder",
				shopOrderId: g.getId(),
				isAssign: false,
				toAdd: k,
				toRemove: b,
				toDecrease: c
			},
			success: function(l) {
				i.getEl().unmask();
				h.removeAll();
				i.close();
				Ext.CustomMessageBox.msg("serialnumbermaintenancelist", bundle.getMsg("socontrol.message.successful"), bundle.getMsg("socontrol.serialnumber.successfullyAssignedSaved"));
				this.refreshGrid()
			},
			failure: function(l) {
				i.getEl().unmask();
				failureHandler(l, i.id)
			}
		})
	},
	onOkRemoveMultipleSN: function() {
		var c = Ext.getCmp("removemultiplefrommaintenance").down("textareafield").getRawValue();
		if (c != "") {
			var a = c.split("\n");
			var b;
			for (b = 0; b < a.length; b++) {
				if (a[b] != "") {
					this.findSNRemoveToSelect(a[b])
				}
			}
			Ext.getCmp("removemultiplefrommaintenance").close()
		}
	},
	onOkAddMultipleSN: function() {
		var c = Ext.getCmp("addmultiplefrommaintenance").down("textareafield").getRawValue();
		if (c != "") {
			var a = c.split("\n");
			var b;
			for (b = 0; b < a.length; b++) {
				if (a[b] != "") {
					this.findSNAddToSelect(a[b])
				}
			}
			Ext.getCmp("addmultiplefrommaintenance").close()
		}
	},
	onCancelRemoveMultipleSN: function() {
		Ext.getCmp("removemultiplefrommaintenance").close()
	},
	onCancelAddMultipleSN: function() {
		Ext.getCmp("addmultiplefrommaintenance").close()
	},
	onRemoveCancel: function() {
		Ext.getCmp("removefrommaintenance").close()
	},
	onAddCancel: function() {
		Ext.getCmp("addfrommaintenance").close()
	},
	onRemoveMultiple: function() {
		Ext.widget("removemultipleserialnumberswindow", {
			id: "removemultiplefrommaintenance"
		}).show();
		Ext.Function.defer(function() {
			Ext.getCmp("multipleSnArea").focus()
		}, 50)
	},
	onAddMultiple: function() {
		Ext.widget("addmultipleserialnumberswindow", {
			id: "addmultiplefrommaintenance"
		}).show();
		Ext.Function.defer(function() {
			Ext.getCmp("multipleSnArea").focus()
		}, 50)
	},
	changeRemainingQty: function() {
		var e = Ext.getCmp("selected");
		if (e == undefined) {
			return
		}
		var f = this.remainingQty - e.store.getCount(),
			c = Ext.getCmp("serialnumbermaintenancelist"),
			d = c.getSelectionModel().getSelection(),
			b = d[0],
			e = Ext.getCmp("addfrommaintenance");
		title = bundle.getMsg("socontrol.addSerialNumber") + " - " + bundle.getMsg("socontrol.soNumber") + ": " + b.data.shopOrderNumber + " - " + bundle.getMsg("socontrol.remainingQty") + ": " + f;
		e.setTitle(title);
		if (f <= 0) {
			Ext.getCmp("results").getView().getPlugin("gridviewdragdrop").dragZone.lock();
			var a = Ext.getCmp("findSNToSelect");
			a.setValue("");
			a.disable();
			Ext.getCmp("findSNToSelectButton").disabled = true
		} else {
			Ext.getCmp("results").getView().getPlugin("gridviewdragdrop").dragZone.unlock();
			Ext.getCmp("findSNToSelect").enable();
			Ext.getCmp("findSNToSelectButton").disabled = false
		}
	},
	addListenerDataChangedToStore: function(a) {
		a.on({
			scope: this,
			datachanged: this.changeRemainingQty,
			clear: this.changeRemainingQty
		})
	},
	itemDoubleClick: function(a, b, c) {
		a.remove(c);
		if (c.dirty) {
			c.reject()
		}
		b.add(c)
	},
	refreshGrid: function() {
		var a = Ext.ComponentQuery.query("#serialnumbermaintenancelist button[id=filter]")[0];
		if (a) {
			a.fireEvent("click", a)
		}
	}
});
Ext.define("SO.model.ShopOrderBrowserFilterModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "soNumberField"
	}, {
		name: "pNumberField"
	}, {
		name: "revField"
	}, {
		name: "soTypeField"
	}, {
		name: "soStatusListField"
	}]
});
Ext.define("SO.model.ShopOrderReleaseFilterModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "soNumberField"
	}, {
		name: "pNumberField"
	}, {
		name: "revField"
	}, {
		name: "soTypeField"
	}, {
		name: "soStatusListField"
	}]
});
Ext.define("SO.model.SerialNumberAssignmentFilterModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "soNumberField"
	}, {
		name: "pNumberField"
	}]
});
Ext.define("SO.model.PrintTravelerFilterModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "soNumberField"
	}, {
		name: "pNumberField"
	}, {
		name: "soTravelerTypeField"
	}]
});
Ext.define("SO.model.ShopOrderCloseFiterModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "soNumberField"
	}]
});
Ext.define("SO.model.SalesOrderLineModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "key",
		type: "int"
	}, {
		name: "orderLine",
		type: "string"
	}, {
		name: "quantity",
		type: "int"
	}, {
		name: "unitsQty",
		type: "int"
	}, {
		name: "partNumber",
		type: "string"
	}, {
		name: "partKey",
		type: "int"
	}, {
		name: "itemTypeCode",
		type: "string"
	}, {
		name: "salesOrderNumber",
		type: "string"
	}, {
		name: "requestedDate",
		type: "string"
	}, {
		name: "promisseDate",
		type: "string"
	}, {
		name: "scheduledShip",
		type: "string"
	}, {
		name: "shipSet",
		type: "string"
	}, {
		name: "customerPart",
		type: "string"
	}, {
		name: "customerPOLine",
		type: "string"
	}, {
		name: "assignedPercentage",
		type: "string"
	}, {
		name: "ediCustPartdDesc",
		type: "string"
	}, {
		name: "moreinfo1",
		type: "string"
	}, {
		name: "moreinfo2",
		type: "string"
	}],
	hasMany: [{
		model: "SO.model.SerialNumberModel",
		name: "serialNumberList"
	}]
});
Ext.define("SO.model.SalesOrderModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "key",
		type: "int"
	}, {
		name: "salesOrder",
		type: "string"
	}, {
		name: "quantity",
		type: "int"
	}, {
		name: "unitQty",
		type: "int"
	}, {
		name: "allUnitsAssigned",
		type: "boolean"
	}, {
		name: "extractType",
		type: "string"
	}],
	hasMany: [{
		model: "SO.model.SalesOrderLineModel",
		name: "orderLineList"
	}],
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "SalesOrderController.getSalesOrderToUpdate"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			messageProperty: "message",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	}
});
Ext.define("SO.view.util.ListProgramErrorWindow", {
	extend: Ext.window.Window,
	alias: "widget.listprogramerrorwindow",
	id: "listprogramerrorwindow",
	model: true,
	closable: false,
	constrain: true,
	renderTo: "xmain",
	initComponent: function(b) {
		var a = this;
		a.title = bundle.getMsg("salesOrder.assignSNResult");
		a.items = a.buildPanel();
		a.border = 0;
		a.modal = true;
		a.layout = {
			type: "hbox",
			align: "center"
		};
		this.callParent(b)
	},
	buildPanel: function() {
		var a = Ext.create("Ext.grid.Panel", {
			viewConfig: {
				markDirty: false
			},
			style: {
				marginTop: "10px",
				marginLeft: "10px",
				marginBottom: "10px"
			},
			store: Ext.getStore("SO.store.ProgramErrorItemStore"),
			id: "errors",
			columns: [{
				xtype: "actioncolumn",
				align: "center",
				width: 50,
				items: [{
					icon: path + "resources/images/16X16/remove.png",
					tooltip: bundle.getMsg("socontrol.message.error")
				}]
			}, {
				header: bundle.getMsg("socontrol.message.information"),
				flex: 1,
				sortable: true,
				dataIndex: "message"
			}],
			stripeRows: true,
			margins: "0 0 0 3",
			width: 450,
			maxHeight: 400,
			maxWidth: 600
		});
		var b = Ext.create("Ext.panel.Panel", {
			width: 470,
			border: 0,
			layout: "column",
			defaults: {
				flex: 1
			},
			items: a,
			dockedItems: {
				xtype: "toolbar",
				dock: "bottom",
				items: ["->",
				{
					xtype: "button",
					text: bundle.getMsg("socontrol.ok"),
					action: "Ok"
				}]
			}
		});
		return b
	}
});
Ext.define("SO.view.util.ShopOrderUtil", {
	statics: {
		isShopOrderReleasable: function(f) {
			if (f == null) {
				return false
			}
			var g = f.serialNumberStatus == 3;
			var h = f.serialNumberStatus == 2;
			var c = f.increasedQuantity > 0;
			var e = f.shopOrderStatus == "R";
			var a = f.shopOrderStatus == "N";
			var b = f.oracleShopOrderStatus == "E";
			var d = f.hold;
			var i = f.oracleShopOrder;
			if (d || (i && b)) {
				return false
			}
			if (a) {
				return true
			}
			if (i) {
				if (e) {
					if (g && !c) {
						return false
					}
					if (h && !c) {
						return false
					}
					return true
				}
			} else {
				if (g && c) {
					return true
				}
			}
			return false
		}
	}
});
Ext.define("SO.view.SalesOrder.AssignSerialNumberWindow", {
	extend: Ext.window.Window,
	alias: "widget.assignserialnumberwindow",
	resizable: false,
	id: "assignserialnumberwindow",
	visibleCombo: true,
	calledFrom: "",
	modal: true,
	constrain: true,
	renderTo: "xmain",
	autoWidth: true,
	autoHeight: true,
	layout: "fit",
	initComponent: function(b) {
		var a = this;
		a.items = a.buildPanel();
		a.bbar = a.buildBottomBar();
		a.title = bundle.getMsg("socontrol.assignSerialNumber");
		a.border = 0;
		this.callParent(b)
	},
	buildPanel: function() {
		var c = Ext.create("Ext.XTemplate", '<tpl for=".">', '<div class="x-boundlist-item">', '<span style="font-weight:bold">{[values.orderLine]}</span><br/>', '<span style="font-size:75%;font-style:italic">{[values.partNumber]}</span>', "</div>", "</tpl>");
		var e = Ext.create("Ext.form.Panel", {
			id: "assignserialnumberform",
			flex: 2.4,
			style: {
				margin: "10px"
			},
			border: 0,
			items: [{
				xtype: "fieldset",
				title: bundle.getMsg("salesOrder.line.information"),
				layout: {
					type: "column",
					columns: 2
				},
				defaults: {
					columnWidth: 0.5
				},
				border: 1,
				collapsible: false,
				items: [{
					xtype: "combobox",
					fieldLabel: bundle.getMsg("salesOrder.line"),
					name: "orderLineCombo",
					id: "orderLineCombo",
					tpl: c,
					valueField: "key",
					displayField: "orderLine",
					labelAlign: "left",
					labelWidth: 60,
					allowBlank: false,
					editable: this.visibleCombo,
					autoSelect: true,
					forceSelection: this.visibleCombo,
					ignoreCustomValueAssertion: false,
					typeAhead: true,
					queryMode: "local",
					store: Ext.create("Ext.data.Store", {
						model: "SO.model.SalesOrderLineModel",
						autoLoad: false,
						proxy: {
							type: "ajax",
							format: "json",
							url: window.windowSOContext.ajaxURL,
							extraParams: {
								resourceID: "SalesOrderController.getAllOrderLinesBySalesOrder",
								salesOrderKey: 0
							},
							reader: {
								root: "data"
							}
						}
					})
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.partNumber"),
					name: "partNumber",
					id: "partNumberField",
					labelAlign: "left",
					labelWidth: 110,
					style: {
						"margin-left": "20px"
					}
				}, {
					xtype: "tbfill",
					width: 200
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("Customer PN"),
					name: "customerPart",
					id: "customerPartField",
					labelWidth: 110,
					labelAlign: "left",
					style: {
						"margin-left": "20px"
					}
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("Promisse"),
					name: "promisseDate",
					id: "promisseDateField",
					labelWidth: 60,
					labelAlign: "left"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("Scheduled to Ship"),
					name: "scheduledShip",
					id: "scheduledShipField",
					labelWidth: 110,
					labelAlign: "left",
					style: {
						"margin-left": "20px"
					}
				}, {
					xtype: "hiddenfield",
					name: "partKey",
					id: "partKeyField"
				}, {
					xtype: "hiddenfield",
					name: "quantity",
					id: "quantityField"
				}, {
					xtype: "hiddenfield",
					name: "unitsQty",
					id: "unitsQtyField"
				}, {
					xtype: "hiddenfield",
					name: "assignedPercentage",
					id: "assignedPercentageField"
				}]
			}]
		});
		var d = Ext.create("Ext.grid.Panel", {
			id: "selected",
			multiSelect: true,
			stripeRows: true,
			scroll: "vertical",
			border: 1,
			bodyPadding: 3,
			style: {
				marginTop: "10px",
				marginLeft: "10px"
			},
			viewConfig: {
				plugins: {
					ptype: "gridviewdragdrop",
					dragGroup: "firstGridDDGroup",
					dropGroup: "secondGridDDGroup"
				},
				listeners: {
					drop: function(j, k, l, i) {
						so_application.getController("SalesOrderController").countSerialsProgressBar()
					}
				}
			},
			columns: [{
				header: bundle.getMsg("Assigned Serials"),
				flex: 1,
				sortable: true,
				dataIndex: "serialNumber"
			}],
			bbar: Ext.create("Ext.toolbar.Paging", {
				border: 0,
				store: Ext.getStore("SerialNumberStore"),
				listeners: {
					afterrender: function() {
						this.down("#refresh").hide()
					}
				}
			}),
			dockedItems: {
				xtype: "panel",
				layout: {
					type: "column",
					columns: 1
				},
				cls: "transparentBackground",
				baseCls: "transparentBackground",
				bodyCls: "transparentBackground",
				items: [{
					xtype: "customtriggerfield",
					fieldLabel: bundle.getMsg("SN"),
					labelAlign: "left",
					labelWidth: 105,
					id: "findSNToSelect",
					value: "",
					columnWidth: 1,
					enableKeyEvents: true,
					triggerCls: "addMultipleSNsTriggerButton",
					onTrigger2Click: function(j) {
						var i = this;
						if (!i.hideTrigger) {
							i.fireEvent("trigger2click", i)
						}
					},
					listeners: {
						blur: function(i) {
							if (i.getValue()) {
								i.setValue(i.getValue().trim())
							}
						}
					}
				}, {
					xtype: "textfield",
					fieldLabel: bundle.getMsg("Container Number"),
					labelAlign: "left",
					labelWidth: 105,
					id: "findCNTRToSelect",
					value: "",
					columnWidth: 1,
					enableKeyEvents: true,
					listeners: {
						blur: function(i) {
							if (i.getValue()) {
								i.setValue(i.getValue().trim())
							}
						}
					}
				}]
			}
		});
		var f = Ext.create("Ext.grid.Panel", {
			id: "removed",
			multiSelect: true,
			stripeRows: true,
			scroll: "vertical",
			border: 1,
			bodyPadding: 3,
			style: {
				marginTop: "10px",
				marginLeft: "10px",
				marginRight: "10px"
			},
			viewConfig: {
				plugins: {
					ptype: "gridviewdragdrop",
					dragGroup: "secondGridDDGroup",
					dropGroup: "firstGridDDGroup"
				},
				listeners: {
					drop: function(j, k, l, i) {
						so_application.getController("SalesOrderController").countSerialsProgressBar()
					}
				}
			},
			columns: [{
				header: bundle.getMsg("Removed Serials"),
				flex: 1,
				sortable: true,
				dataIndex: "serialNumber"
			}],
			dockedItems: {
				xtype: "panel",
				layout: {
					type: "column",
					columns: 1
				},
				cls: "transparentBackground",
				baseCls: "transparentBackground",
				bodyCls: "transparentBackground",
				items: [{
					xtype: "customtriggerfield",
					fieldLabel: bundle.getMsg("SN"),
					labelAlign: "left",
					labelWidth: 105,
					id: "findSNToRemove",
					value: "",
					columnWidth: 1,
					enableKeyEvents: true,
					triggerCls: "addMultipleSNsTriggerButton",
					onTrigger2Click: function(j) {
						var i = this;
						if (!i.hideTrigger) {
							i.fireEvent("trigger2click", i)
						}
					},
					listeners: {
						blur: function(i) {
							if (i.getValue()) {
								i.setValue(i.getValue().trim())
							}
						}
					}
				}, {
					xtype: "textfield",
					fieldLabel: bundle.getMsg("Container Number"),
					labelAlign: "left",
					labelWidth: 105,
					id: "findCNTRToRemove",
					value: "",
					columnWidth: 1,
					enableKeyEvents: true,
					listeners: {
						blur: function(i) {
							if (i.getValue()) {
								i.setValue(i.getValue().trim())
							}
						}
					}
				}]
			}
		});
		var a = Ext.create("Ext.container.Container", {
			flex: 9,
			layout: {
				type: "hbox",
				align: "stretch"
			},
			defaults: {
				flex: 1
			},
			items: [d, f]
		});
		var b = Ext.create("Ext.form.FieldSet", {
			title: bundle.getMsg("Manage Serials"),
			flex: 7.6,
			border: 1,
			collapsible: false,
			disabled: true,
			id: "assignedFieldSet",
			style: {
				marginBottom: "10px",
				marginLeft: "10px",
				marginRight: "10px"
			},
			layout: {
				type: "vbox",
				align: "stretch"
			},
			items: [{
				xtype: "progressbar",
				id: "summarySerialProgressBar",
				style: {
					marginTop: "5px",
					marginLeft: "5px",
					marginRight: "5px",
					marginBottom: "5px"
				},
				border: 1
			},
			a]
		});
		var h = Ext.getCmp("somainwindow");
		var g = Ext.create("Ext.panel.Panel", {
			width: 0.62 * h.getWidth(),
			height: 0.85 * h.getHeight(),
			border: 0,
			layout: {
				type: "vbox",
				align: "stretch"
			},
			items: [e, b]
		});
		return g
	},
	buildBottomBar: function() {
		var a;
		a = Ext.create("Ext.toolbar.Toolbar", {
			maxHeight: 30,
			border: 0,
			items: ["->",
			{
				xtype: "button",
				text: bundle.getMsg("socontrol.reset"),
				action: "reset"
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.save"),
				action: "onSave"
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.cancel"),
				action: "onCancel"
			}]
		});
		return a
	}
});
Ext.define("SO.view.SalesOrder.SalesOrderInformation", {
	extend: Ext.form.Panel,
	alias: "widget.salesorderinformation",
	id: "salesorderinformation",
	border: 0,
	resizable: false,
	autoScroll: true,
	loadMask: true,
	autoWidth: true,
	autoHeight: true,
	viewOnly: false,
	initComponent: function() {
		var a = this;
		a.items = a.buildPanel();
		a.layout = "fit";
		a.dockedItems = a.buildButtons();
		a.title = bundle.getMsg("salesOrder.details");
		this.callParent(arguments)
	},
	buildButtons: function() {
		var a = ({
			xtype: "toolbar",
			dock: "bottom",
			items: ["->",
			{
				xtype: "button",
				text: bundle.getMsg("socontrol.close"),
				handler: function() {
					so_application.getController("SO.controller.ShopOrderController").pushScreen("salesorderlist", null)
				}
			}]
		});
		return a
	},
	buildPanel: function() {
		var a;
		a = Ext.create("Ext.form.Panel", {
			layout: {
				type: "vbox",
				align: "stretch"
			},
			id: "mainPanel",
			autoScroll: true,
			width: "100%",
			height: "100%",
			border: 0,
			items: [{
				xtype: "panel",
				title: bundle.getMsg("salesOrder.information"),
				collapsible: true,
				margin: "5 5 5 5",
				padding: "3 3 3 3",
				items: this.getStandardItemsPanel()
			}]
		});
		return a
	},
	getStandardItemsPanel: function() {
		var a;
		a = Ext.create("Ext.form.Panel", {
			border: 0,
			id: "salesOrderStandardPanel",
			autoWidth: true,
			autoHeight: true,
			layout: {
				type: "column",
				columns: 3
			},
			bodyPadding: "15, 15, 15, 15",
			defaults: {
				labelClsExtra: "labelFieldDisplayCss",
				columnWidth: 0.33,
				labelWidth: 140,
				labelAlign: "right"
			},
			items: [{
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.id"),
				name: "key",
				id: "key"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.extractType"),
				name: "extractType"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.address1"),
				name: "address1",
				labelWidth: 70
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.salesOrderNumber"),
				name: "salesOrder",
				id: "salesOrder"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.tellabsDeliveryDate"),
				name: "deliveryDate"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.address2"),
				name: "address2",
				labelWidth: 70
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.customerPONumber"),
				name: "customerPoNumber"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.programManagerName"),
				name: "programManagerName"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.address3"),
				name: "address3",
				labelWidth: 70
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.customerNumber"),
				name: "customerNumber"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.additionalPONumber"),
				name: "addlPoNumber"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.country"),
				name: "country",
				labelWidth: 70
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.customerName"),
				name: "customerName"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.orderDate"),
				name: "orderedDate"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.state"),
				name: "state",
				labelWidth: 70
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.shiptoCustPONumber"),
				name: "shiptoCustPoNumber"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.postCode"),
				name: "postCode"
			}, {
				xtype: "progressbar",
				id: "slInfoSerialProgressBar",
				border: 1
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.carrier"),
				name: "carrier"
			}]
		});
		return a
	}
});
Ext.define("SO.view.SalesOrder.SalesOrderFilter", {
	extend: Ext.panel.Panel,
	alias: "widget.salesorderfilter",
	height: "100%",
	width: "100%",
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("socontrol.salesOrderTitle");
		a.store = Ext.getStore("SalesOrderStore");
		a.border = 0;
		a.items = a.buildPanel();
		this.callParent(arguments)
	},
	listeners: {
		afterrender: function() {
			Ext.getCmp("salesOrderField").focus()
		}
	},
	buildPanel: function() {
		var a = [{
			xtype: "container",
			layout: {
				type: "vbox",
				align: "stretch"
			},
			width: "100%",
			border: 0,
			items: [{
				xtype: "panel",
				layout: {
					type: "column"
				},
				border: 0,
				style: {
					padding: "10px",
					marginRight: "0px"
				},
				items: [{
					xtype: "panel",
					border: 0,
					baseCls: "float_right_panel",
					items: [{
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("salesOrder.soNumber"),
						labelAlign: "top",
						name: "salesOrder",
						width: 130,
						idProperty: "salesOrder",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss",
						id: "salesOrderField"
					}, {
						xtype: "combobox",
						fieldLabel: bundle.getMsg("salesOrder.fullLine"),
						labelAlign: "top",
						name: "isFull",
						idProperty: "isFull",
						valueField: "id",
						displayField: "isFull",
						value: -1,
						width: 130,
						cls: "comboFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "comboFilterCss",
						editable: false,
						store: new Ext.data.ArrayStore({
							fields: ["id", "isFull"],
							listeners: {
								load: function(b) {
									b.sort("isFull", "ASC")
								}
							},
							data: [
								[0, bundle.getMsg("label.yes")],
								[1, bundle.getMsg("label.no")],
								[-1, bundle.getMsg("label.all")]
							]
						})
					}, {
						xtype: "panel",
						layout: {
							type: "vbox"
						},
						id: "painelButtons",
						baseCls: "float_right_panel",
						style: {
							marginLeft: "15px"
						},
						border: 0,
						items: [{
							xtype: "hiddenfield",
							name: "soFilteredHidden",
							id: "soFilteredHidden",
							idProperty: "soFilteredHidden",
							value: ""
						}, {
							xtype: "button",
							id: "filter",
							text: bundle.getMsg("socontrol.filter"),
							action: "salesOrderFilter",
							iconCls: "filterButtonIcon"
						}, {
							xtype: "tbspacer",
							height: 5
						}, {
							xtype: "button",
							id: "clear",
							text: bundle.getMsg("socontrol.clear"),
							action: "salesOrderClear",
							iconCls: "clearButtonIcon"
						}]
					}]
				}]
			}]
		}];
		return a
	}
});
Ext.define("SO.view.SalesOrder.SalesOrderList", {
	extend: Ext.grid.Panel,
	alias: "widget.salesorderlist",
	id: "salesorderlist",
	autoWidth: true,
	autoHeight: true,
	initComponent: function() {
		var a = this;
		a.border = 0;
		a.dockedItems = a.buildFilterTopBar();
		a.stripeRows = false;
		a.store = Ext.getStore("SalesOrderListStore");
		a.columns = a.buildColumns();
		a.tbar = a.buildDockedItemsBar();
		a.bbar = a.buildBottomBar();
		a.selModel = Ext.create("Ext.selection.CheckboxModel", {
			mode: "SINGLE",
			showHeaderCheckbox: false,
			listeners: {
				selectionchange: function(g, d) {
					var f = Ext.getCmp("addToolbar"),
						b = Ext.getCmp("printToolbar"),
						e = Ext.getCmp("infoToolbar"),
						c = d[0];
					if (c) {
						f.setDisabled(false);
						b.setDisabled(false);
						e.setDisabled(false)
					} else {
						f.setDisabled(true);
						e.setDisabled(true);
						b.setDisabled(true)
					}
				}
			}
		});
		a.on({
			afterrender: function() {
				checkPermissionsByContainer(a)
			}
		});
		a.callParent(arguments)
	},
	buildDockedItemsBar: function() {
		var a;
		a = Ext.create("Ext.toolbar.Toolbar", {
			items: [{
				icon: path + "resources/images/16X16/info.png",
				text: bundle.getMsg("socontrol.salesOrderSnAssignment.label.salesOrderInformation"),
				tooltip: bundle.getMsg("socontrol.salesOrderSnAssignment.label.salesOrderInformation"),
				id: "infoToolbar",
				handler: this.openSalesInfoWindow,
				scope: this,
				disabled: true
			}, {
				icon: path + "resources/images/16X16/manage.png",
				text: bundle.getMsg("socontrol.manageSerials"),
				tooltip: bundle.getMsg("socontrol.manageSerials"),
				id: "addToolbar",
				action: "onOpenAddPanelFromList",
				scope: this,
				disabled: true,
				actionKey: "shopOrder.salesOrderBrowser.manageSerial"
			}, {
				icon: path + "resources/images/16X16/print.png",
				text: bundle.getMsg("socontrol.print"),
				tooltip: bundle.getMsg("socontrol.printExportAssignedSerialNumber"),
				id: "printToolbar",
				action: "onPrintExportSalesOrderList",
				scope: this,
				disabled: true,
				actionKey: "shopOrder.salesOrderBrowser.printAssSerial"
			}, {
				icon: path + "resources/images/16X16/reload.png",
				text: bundle.getMsg("button.reloadFromERP"),
				tooltip: bundle.getMsg("button.reloadFromERP"),
				scope: this,
				action: "onReloadSalesOrder",
				id: "onReloadSalesOrder",
				hidden: true
			}, "->",
			{
				icon: path + "resources/images/16X16/requestSalesOrder.png",
				text: bundle.getMsg("salesOrder.requestSalesOrder"),
				tooltip: bundle.getMsg("salesOrder.requestSalesOrder"),
				id: "requestSalesOrderToolbar",
				action: "onrequestSalesOrder",
				scope: this,
				actionKey: "shopOrder.salesOrderBrowser.requestSalesOrder"
			}, {
				icon: path + "resources/images/16X16/print.png",
				tooltip: bundle.getMsg("socontrol.printExportFiltered"),
				scope: this,
				action: "printFiltered",
				id: "salesOrderPrintTop",
				actionKey: "shopOrder.salesOrderBrowser.printFilteredSO"
			}]
		});
		return a
	},
	buildColumns: function() {
		var a = [];
		a = [{
			header: bundle.getMsg("socontrol.salesOrderNumber"),
			width: 120,
			flex: 1,
			sortable: true,
			dataIndex: "salesOrder"
		}, {
			header: bundle.getMsg("socontrol.release.quantityTable"),
			width: 60,
			flex: 1,
			sortable: true,
			dataIndex: "quantity"
		}, {
			header: bundle.getMsg("socontrol.salesOrderSnAssignment.label.lineUnitQty"),
			width: 60,
			flex: 1,
			sortable: true,
			dataIndex: "unitQty"
		}, {
			header: bundle.getMsg("socontrol.extractType"),
			width: 100,
			flex: 1,
			sortable: true,
			dataIndex: "extractType"
		}];
		return a
	},
	buildFilterTopBar: function() {
		var a;
		a = Ext.create("SO.view.SalesOrder.SalesOrderFilter");
		return a
	},
	buildBottomBar: function() {
		var a;
		a = Ext.create("Ext.Custom.CustomPaging", {
			border: 0,
			store: Ext.getStore("SalesOrderListStore"),
			displayInfo: false,
			beforePageText: bundle.getMsg("socontrol.page"),
			afterPageText: ""
		});
		a.add("->");
		a.add({
			icon: path + "resources/images/16X16/print.png",
			tooltip: bundle.getMsg("socontrol.printExportFiltered"),
			scope: this,
			action: "printFiltered",
			id: "salesOrderPrintBottom"
		});
		a.doLayout();
		return a
	},
	openSalesInfoWindow: function() {
		var b = Ext.getCmp("salesorderlist");
		var c = b.getSelectionModel().getSelection();
		var a = c[0];
		if (a) {
			b.fireEvent("iconclick", a, {
				viewOnly: !checkPermission("shopOrder.salesOrderBrowser.salesOrderInformation")
			})
		}
	}
});
Ext.define("SO.view.ShopOrderRelease.ShopOrderReleaseFilter", {
	extend: Ext.panel.Panel,
	alias: "widget.shoporderreleasefilter",
	id: "shoporderreleasefilter",
	height: "100%",
	width: "100%",
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("socontrol.releaseTitle"), a.store = Ext.getStore("ShopOrderReleaseStore");
		a.border = 0;
		a.items = a.buildPanel();
		this.callParent(arguments)
	},
	listeners: {
		afterrender: function() {
			Ext.getCmp("soNumberField").focus()
		}
	},
	buildPanel: function() {
		var a = [{
			xtype: "container",
			layout: {
				type: "vbox",
				align: "stretch"
			},
			width: "100%",
			border: 0,
			items: [{
				xtype: "panel",
				layout: {
					type: "column"
				},
				border: 0,
				style: {
					padding: "10px",
					marginRight: "0px"
				},
				items: [{
					xtype: "panel",
					border: 0,
					baseCls: "float_right_panel",
					items: [{
						xtype: "hiddenfield",
						name: "soFilteredHidden",
						id: "soFilteredHidden",
						width: 130,
						idProperty: "soFilteredHidden",
						value: ""
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.soNumber"),
						labelAlign: "top",
						name: "soNumberField",
						idProperty: "soNumberField",
						id: "soNumberField",
						width: 130,
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.partNumber"),
						labelAlign: "top",
						name: "pNumberField",
						width: 130,
						idProperty: "pNumberField",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.revisionTable"),
						labelAlign: "top",
						name: "revField",
						width: 130,
						idProperty: "revField",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "combobox",
						fieldLabel: bundle.getMsg("socontrol.soType"),
						labelAlign: "top",
						name: "soTypeField",
						idProperty: "soTypeField",
						valueField: "id",
						displayField: "soTypeDescription",
						value: 3,
						width: 130,
						cls: "comboFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "comboFilterCss",
						editable: true,
						forceSelection: true,
						queryMode: "local",
						store: new Ext.data.ArrayStore({
							fields: ["id", "soTypeDescription"],
							listeners: {
								load: function(b) {
									b.sort("soTypeDescription", "ASC")
								}
							},
							data: [
								[1, bundle.getMsg("socontrol.soOracle")],
								[2, bundle.getMsg("socontrol.soStandard")],
								[3, bundle.getMsg("socontrol.all")]
							]
						})
					}, {
						xtype: "combobox",
						fieldLabel: bundle.getMsg("socontrol.status"),
						labelAlign: "top",
						name: "soStatusListField",
						idProperty: "soStatusListField",
						multiSelect: true,
						valueField: "id",
						displayField: "soStatusDescription",
						value: 5,
						width: 130,
						cls: "comboFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "comboFilterCss",
						editable: false,
						store: new Ext.data.ArrayStore({
							fields: ["id", "soStatusDescription"],
							listeners: {
								load: function(b) {
									b.sort("soStatusDescription", "ASC")
								}
							},
							data: [
								[1, bundle.getMsg("socontrol.soReleasable")],
								[2, bundle.getMsg("socontrol.soNotReleasable")],
								[3, bundle.getMsg("socontrol.soMapped")],
								[4, bundle.getMsg("socontrol.soUnmapped")],
								[5, bundle.getMsg("socontrol.all")]
							]
						})
					}, {
						xtype: "panel",
						layout: {
							type: "vbox"
						},
						id: "painelButtons",
						baseCls: "float_right_panel",
						style: {
							marginLeft: "15px"
						},
						border: 0,
						items: [{
							xtype: "button",
							id: "filter",
							text: bundle.getMsg("socontrol.filter"),
							action: "releaseFilter",
							iconCls: "filterButtonIcon"
						}, {
							xtype: "tbspacer",
							height: 5
						}, {
							xtype: "button",
							id: "clear",
							text: bundle.getMsg("socontrol.clear"),
							action: "releaseClear",
							iconCls: "clearButtonIcon"
						}]
					}]
				}]
			}]
		}];
		return a
	}
});
Ext.define("Common.model.PartNumberModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "id",
		mapping: "id"
	}, {
		name: "partNumber",
		mapping: "partNumber"
	}, {
		name: "description",
		mapping: "description"
	}]
});
Ext.define("Common.view.editor.PartNumberEditor", {
	extend: Ext.form.ComboBox,
	name: "partNumber",
	alias: "widget.partnumbereditor",
	id: "partnumbereditor",
	displayField: "partNumber",
	valueField: "id",
	minChars: 3,
	pageSize: 25,
	forceSelection: true,
	queryDelay: 500,
	typeAhead: false,
	hideTrigger: true,
	anchor: "100%",
	submitEmptyText: false,
	listeners: {
		blur: function(a) {
			if (a.getStore().loading == true) {
				a.clearValue();
				a.value = "";
				a.inputEl.dom.value = ""
			}
		}
	},
	initComponent: function() {
		this.fieldLabel = bundle.getMsg("socontrol.maintenance.partNumber.partNumber");
		this.emptyText = bundle.getMsg("socontrol.msgSelectPart");
		this.store = Ext.create("Ext.data.Store", {
			model: "Common.model.PartNumberModel",
			pageSize: 25,
			remoteSort: false,
			autoLoad: false,
			proxy: {
				type: "ajax",
				format: "json",
				url: window.windowSOContext.ajaxURL,
				appendId: false,
				extraParams: {
					resourceID: "GenericFetchController.getPartNumbers"
				},
				reader: {
					root: "data",
					totalProperty: "totalCount"
				}
			}
		});
		this.listConfig = {
			loadingText: bundle.getMsg("socontrol.msgSearch"),
			emptyText: bundle.getMsg("socontrol.msgNoMatchingPart")
		};
		this.callParent(arguments)
	}
});
Ext.define("Common.view.editor.RevisionEditor", {
	extend: Ext.form.ComboBox,
	alias: "widget.revisioneditor",
	id: "revisioneditor",
	name: "revision",
	displayField: "revision",
	valueField: "revision",
	forceSelection: true,
	typeAhead: true,
	anchor: "100%",
	submitEmptyText: false,
	queryMode: "local",
	initComponent: function() {
		this.fieldLabel = bundle.getMsg("socontrol.release.revision");
		this.emptyText = bundle.getMsg("socontrol.msgSelectRevision");
		this.store = Ext.create("Ext.data.Store", {
			fields: ["revision"],
			proxy: {
				type: "ajax",
				format: "json",
				url: window.windowSOContext.ajaxURL,
				appendId: false,
				extraParams: {
					resourceID: "GenericFetchController.getRevisionByPart",
					partId: 0
				},
				reader: {
					root: "data",
					totalProperty: "totalCount"
				}
			}
		});
		this.listConfig = {
			loadingText: bundle.getMsg("socontrol.msgSearch"),
			emptyText: bundle.getMsg("socontrol.msgNoMatchingRevision")
		};
		this.callParent(arguments)
	}
});
Ext.define("SO.view.ShopOrderRelease.ShopOrderFormWindow", {
	extend: Ext.Window,
	alias: "widget.shoporderformwindow",
	id: "shoporderformwindow",
	isEdit: false,
	viewOnly: false,
	width: 500,
	height: 300,
	modal: true,
	constrain: true,
	renderTo: "xmain",
	layout: "fit",
	initComponent: function() {
		var a = this;
		a.title = a.isEdit ? bundle.getMsg("socontrol.editStandardShopOrder") : bundle.getMsg("socontrol.addStandardShopOrder");
		a.items = a.buildItems();
		a.callParent(arguments)
	},
	buildItems: function() {
		var b = this;
		var a = {
			xtype: "form",
			layout: "form",
			bodyPadding: "5 5 0",
			width: 350,
			fieldDefaults: {
				labelWidth: "150",
				labelAlign: "right"
			},
			defaultType: "customtextfield",
			items: [{
				fieldLabel: bundle.getMsg("socontrol.release.soNumber"),
				name: "shopOrderNumber",
				allowBlank: false,
				maxLength: 50,
				id: "shopOrderNumberField",
				readOnly: b.viewOnly,
				listeners: {
					blur: function(c) {
						c.setValue(Ext.String.trim(this.getValue()).toUpperCase())
					}
				}
			}, {
				xtype: "partnumbereditor",
				name: "partId",
				allowBlank: false,
				readOnly: b.viewOnly
			}, {
				fieldLabel: bundle.getMsg("socontrol.release.quantity"),
				name: "quantity",
				xtype: "numberfield",
				allowBlank: false,
				allowDecimals: false,
				minValue: 1,
				maxValue: 500000,
				readOnly: b.viewOnly
			}, {
				xtype: "revisioneditor",
				name: "revision",
				readOnly: b.viewOnly
			}, {
				fieldLabel: bundle.getMsg("socontrol.release.userDefined"),
				name: "userDefined",
				maxLength: 20,
				readOnly: b.viewOnly
			}, {
				fieldLabel: bundle.getMsg("socontrol.completionDate"),
				name: "dueDate",
				xtype: "datefield",
				invalidText: "{0} is not a valid date - it must be in the format mm/dd/YYYY",
				submitFormat: "mm/dd/YY",
				emptyText: "Select a Date ...",
				minValue: new Date(),
				submitEmptyText: false,
				readOnly: b.viewOnly
			}],
			dockedItems: {
				xtype: "toolbar",
				dock: "bottom",
				items: ["->",
				{
					action: "reset",
					text: bundle.getMsg("socontrol.reset"),
					hidden: b.viewOnly
				}, {
					action: "save",
					text: bundle.getMsg("socontrol.save"),
					hidden: b.viewOnly
				}, {
					action: "cancel",
					text: bundle.getMsg("socontrol.cancel")
				}]
			}
		};
		return a
	}
});
Ext.define("SO.view.ShopOrderRelease.ShopOrderReleaseList", {
	extend: Ext.grid.Panel,
	alias: "widget.shoporderreleaselist",
	id: "shoporderreleaselist",
	autoWidth: true,
	autoHeight: true,
	initComponent: function() {
		var a = this;
		a.border = 0;
		a.stripeRows = false;
		a.store = Ext.getStore("ShopOrderReleaseStore");
		a.selModel = Ext.create("Ext.selection.CheckboxModel", {
			scope: this,
			mode: "SINGLE",
			showHeaderCheckbox: false,
			listeners: {
				scope: this,
				selectionchange: this.onSelectionChange
			}
		});
		a.columns = a.buildColumns();
		a.tbar = a.buildDockedItemsBar();
		a.dockedItems = a.buildFilterTopBar();
		a.bbar = a.buildPagingBottomBar();
		a.viewConfig = a.buildViewConfig();
		a.on({
			afterrender: function() {
				checkPermissionsByContainer(a)
			}
		});
		a.callParent(arguments)
	},
	buildViewConfig: function() {
		var a = {
			getRowClass: function(b, e, d, c) {
				if (b.get("serialNumberStatus") == 2) {
					return "rowSoGreen"
				} else {
					if (b.get("serialNumberStatus") == 3) {
						return "rowSoRed"
					} else {
						return "rowSoBlack"
					}
				}
			}
		};
		return a
	},
	onSelectionChange: function(c, b) {
		var a = b[0];
		Ext.getCmp("editsotb").setDisabled(true);
		Ext.getCmp("deletesotb").setDisabled(true);
		Ext.getCmp("mapsotb").setDisabled(true);
		Ext.getCmp("mapsotb").setIcon(path + "resources/images/16X16/map.png");
		Ext.getCmp("releasesotb").setDisabled(true);
		if (a) {
			Ext.getCmp("editsotb").setDisabled(a.data.oracleShopOrder);
			this.setReleaseBtnDisabledAndToolTip(a.data);
			this.setMapBtnDisabledAndToolTip(a.data);
			Ext.getCmp("deletesotb").setDisabled(a.data.oracleShopOrder)
		}
	},
	getShopOrderMapIcon: function(b) {
		var a = (b.mappingId != null && b.mappingId > 0);
		if (a) {
			return path + "resources/images/16X16/mapGreen.png"
		} else {
			return path + "resources/images/16X16/map.png"
		}
	},
	isShopOrderMapable: function(b) {
		if (b == null) {
			return false
		}
		var a = b.shopOrderStatus == "R",
			c = b.oracleShopOrder;
		if (!c) {
			return false
		}
		if (a) {
			return false
		}
		return true
	},
	setMapBtnDisabledAndToolTip: function(b) {
		var c = !this.isShopOrderMapable(b);
		Ext.getCmp("mapsotb").setDisabled(c);
		var g = bundle.getMsg("socontrol.mapShopOrder");
		if (c) {
			var f = "";
			var a = b.shopOrderStatus == "R";
			if (a) {
				f += "<li style='color:red'>" + bundle.getMsg("error.progress.socontrol.shopOrderReleasedOrClosed") + "</li>"
			}
			g = bundle.getMsg("socontrol.mapShopOrder") + f
		}
		if (Ext.getCmp("mapToolTip")) {
			try {
				Ext.getCmp("mapToolTip").html = g
			} catch (d) {}
			try {
				Ext.getCmp("mapToolTip").body.dom.innerHTML = g
			} catch (d) {}
		} else {
			Ext.create("Ext.tip.ToolTip", {
				id: "mapToolTip",
				target: "mapsotb",
				html: g
			})
		}
		Ext.getCmp("mapsotb").setIcon(this.getShopOrderMapIcon(b))
	},
	setReleaseBtnDisabledAndToolTip: function(j) {
		var d = !SO.view.util.ShopOrderUtil.isShopOrderReleasable(j);
		Ext.getCmp("releasesotb").setDisabled(d);
		var a = bundle.getMsg("socontrol.releaseShopOrder");
		if (d) {
			var b = "";
			var c = j.oracleShopOrderStatus == "E";
			var g = j.hold;
			var k = j.oracleShopOrder;
			var f = j.increasedQuantity > 0;
			var h = j.shopOrderStatus == "R";
			if (k && c) {
				b += "<li style='color:red'>" + bundle.getMsg("socontrol.mapping.reasons.statusE") + "</li>"
			}
			if (h && !f) {
				b += "<li style='color:red'>" + bundle.getMsg("socontrol.mapping.reasons.released") + "</li>"
			}
			a = bundle.getMsg("socontrol.releaseShopOrder") + b
		}
		if (Ext.getCmp("releaseToolTip")) {
			try {
				Ext.getCmp("releaseToolTip").html = a
			} catch (i) {}
			try {
				Ext.getCmp("releaseToolTip").body.dom.innerHTML = a
			} catch (i) {}
		} else {
			Ext.create("Ext.tip.ToolTip", {
				id: "releaseToolTip",
				target: "releasesotb",
				html: a
			})
		}
	},
	buildColumns: function() {
		var a = [];
		a = [{
			header: bundle.getMsg("socontrol.soNumber"),
			width: 140,
			dataIndex: "shopOrderNumber",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.partNumber"),
			flex: 1,
			sortable: true,
			dataIndex: "partNumberDataIndex"
		}, {
			header: bundle.getMsg("socontrol.release.oracleSO"),
			flex: 1,
			dataIndex: "oracleShopOrder",
			sortable: true,
			renderer: function(f, c, b, h, e, d, g) {
				if (f == true) {
					return '<input type="checkbox" disabled checked/>'
				} else {
					return '<input type="checkbox" disabled />'
				}
			}
		}, {
			header: bundle.getMsg("socontrol.status"),
			flex: 1,
			dataIndex: "shopOrderStatus",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.quantityTable"),
			flex: 1,
			dataIndex: "quantity",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.boardsPerPanelList"),
			flex: 1,
			dataIndex: "boardsPerPanel",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.revisionTable"),
			flex: 1,
			dataIndex: "revision",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.startDate"),
			flex: 1,
			dataIndex: "startDate",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.completionDate"),
			flex: 1,
			dataIndex: "dueDate",
			sortable: true
		}];
		return a
	},
	buildDockedItemsBar: function() {
		var b, a = checkPermission("shopOrder.shopOrderRelease.editShopOrder");
		b = Ext.create("Ext.toolbar.Toolbar", {
			items: [{
				id: "addsotb",
				action: "add",
				actionKey: "shopOrder.shopOrderRelease.addShopOrder",
				icon: path + "resources/images/16X16/add.png",
				text: bundle.getMsg("socontrol.add"),
				tooltip: bundle.getMsg("socontrol.add"),
				scope: this
			}, {
				id: "editsotb",
				action: "edit",
				icon: a ? path + "resources/images/16X16/edit.png" : path + "resources/images/16X16/view.png",
				text: a ? bundle.getMsg("socontrol.edit") : bundle.getMsg("socontrol.view"),
				tooltip: bundle.getMsg("socontrol.edit"),
				disabled: true,
				scope: this
			}, {
				id: "mapsotb",
				action: "map",
				icon: path + "resources/images/16X16/map.png",
				text: bundle.getMsg("socontrol.mapShopOrder"),
				disabled: true,
				scope: this,
				handler: this.openMapWindow
			}, {
				id: "releasesotb",
				action: "release",
				actionKey: "shopOrder.shopOrderRelease.releaseShopOrder",
				icon: path + "resources/images/16X16/release.png",
				text: bundle.getMsg("socontrol.releaseShopOrder"),
				disabled: true,
				handler: this.openReleaseWindow,
				scope: this
			}, {
				id: "deletesotb",
				action: "delete",
				actionKey: "shopOrder.shopOrderRelease.deleteShopOrder",
				icon: path + "resources/images/16X16/delete.png",
				text: bundle.getMsg("socontrol.delete"),
				tooltip: bundle.getMsg("socontrol.delete"),
				disabled: true,
				scope: this
			}, "->",
			{
				scope: this,
				text: bundle.getMsg("socontrol.closeShopOrder"),
				iconCls: "releaseClose",
				action: "shopordercloselist",
				ItemId: "releaseClose"
			}, {
				icon: path + "resources/images/16X16/print.png",
				tooltip: bundle.getMsg("socontrol.printExportFiltered"),
				scope: this,
				action: "printFiltered",
				actionKey: "shopOrder.shopOrderRelease.printExportFilteredShopOrder",
				id: "releasePrintTop"
			}, {
				icon: path + "resources/images/16X16/csv.png",
				tooltip: bundle.getMsg("socontrol.printExportFiltered"),
				scope: this,
				action: "printFiltered",
				actionKey: "shopOrder.shopOrderRelease.printExportFilteredShopOrder",
				id: "releaseCsvPrintTop"
			}]
		});
		return b
	},
	openMapWindow: function() {
		scope = this;
		var c = this;
		var b = Ext.getCmp("shoporderreleaselist").getSelectionModel().getSelection();
		var a = b[0];
		if (a) {
			c.getDetails(a, "map")
		}
	},
	maskUnmask: function(b) {
		var a = Ext.getCmp("shoporderreleaselist");
		if (b) {
			a.getEl().mask("Loading...")
		} else {
			a.getEl().unmask()
		}
	},
	openReleaseWindow: function() {
		scope = this;
		var c = this;
		var b = Ext.getCmp("shoporderreleaselist").getSelectionModel().getSelection();
		var a = b[0];
		if (a) {
			c.getDetails(a, "release")
		}
	},
	getDetails: function(a, d) {
		scope = this;
		var c = this;
		c.maskUnmask(true);
		var b = Ext.ModelManager.getModel("SO.model.ShopOrderModel");
		b.getProxy().extraParams.resourceID = "ShopOrderController.findShopOrder";
		b.load(a.data.id, {
			scope: this,
			failure: function(f, e) {
				Ext.Msg.show({
					scope: this,
					title: "Error",
					msg: bundle.getMsg("error.progress.nextgen.shopOrderNotFound"),
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
				c.maskUnmask(false)
			},
			success: function(f, e) {
				c.maskUnmask(false);
				if (d == "map") {
					Ext.getCmp("shoporderreleaselist").fireEvent("iconclick", "map", this.id, f)
				}
				if (d == "release") {
					Ext.getCmp("shoporderreleaselist").fireEvent("iconclick", "release", this.id, f)
				}
			}
		})
	},
	buildFilterTopBar: function() {
		var a;
		a = Ext.create("SO.view.ShopOrderRelease.ShopOrderReleaseFilter", {});
		return a
	},
	buildPagingBottomBar: function() {
		var a;
		a = Ext.create("Ext.Custom.CustomPaging", {
			store: Ext.getStore("ShopOrderReleaseStore"),
			displayInfo: false,
			beforePageText: bundle.getMsg("socontrol.page"),
			afterPageText: ""
		});
		a.add("->");
		a.add({
			icon: path + "resources/images/16X16/print.png",
			tooltip: bundle.getMsg("socontrol.printExportFiltered"),
			scope: this,
			action: "printFiltered",
			actionKey: "shopOrder.shopOrderRelease.printExportFilteredShopOrder",
			id: "releasePrintBottom"
		});
		a.add({
			icon: path + "resources/images/16X16/csv.png",
			tooltip: bundle.getMsg("socontrol.printExportFiltered"),
			scope: this,
			action: "printFiltered",
			actionKey: "shopOrder.shopOrderRelease.printExportFilteredShopOrder",
			id: "releaseCsvPrintBottom"
		});
		a.doLayout();
		return a
	}
});
Ext.define("SO.view.ShopOrderRelease.SelectMappingTypeWindow", {
	extend: Ext.window.Window,
	alias: "widget.selectmappingtypewindow",
	id: "selectmappingtypewindow",
	closable: false,
	soRecord: null,
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("socontrol.release.mapping.selectMappingType");
		a.border = 1;
		a.modal = true;
		a.constrain = true;
		a.renderTo = "xmain";
		a.items = a.buildItems();
		a.dockedItems = a.buildDockedItems();
		this.callParent(arguments)
	},
	buildItems: function() {
		var a = [{
			xtype: "fieldcontainer",
			margin: 5,
			fieldLabel: bundle.getMsg("socontrol.release.mapping.selectMappingType"),
			labelWidth: 200,
			labelAlign: "top",
			defaultType: "radiofield",
			width: 150,
			height: 100,
			defaults: {
				flex: 1
			},
			style: {
				backgroundColor: "white"
			},
			layout: "hbox",
			items: [{
				boxLabel: bundle.getMsg("socontrol.location"),
				name: "mapping",
				inputValue: "location",
				id: "location"
			}, {
				boxLabel: bundle.getMsg("socontrol.process"),
				name: "mapping",
				inputValue: "process",
				id: "process"
			}]
		}];
		return a
	},
	buildDockedItems: function() {
		var a = {
			xtype: "toolbar",
			dock: "bottom",
			items: ["->",
			{
				xtype: "button",
				text: bundle.getMsg("socontrol.ok"),
				action: "onOkSelectMappingType"
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.cancel"),
				action: "onCancelMappingType"
			}]
		};
		return a
	}
});
Ext.define("SO.view.ShopOrderRelease.ShopOrderCloseFilter", {
	extend: Ext.panel.Panel,
	alias: "widget.shoporderclosefilter",
	id: "shoporderclosefilter",
	height: "100%",
	width: "100%",
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("socontrol.releaseTitle"), a.store = Ext.getStore("ShopOrderCloseStore");
		a.border = 0;
		a.items = a.buildPanel();
		this.callParent(arguments)
	},
	listeners: {
		afterrender: function() {
			Ext.getCmp("soNumberField").focus()
		}
	},
	buildPanel: function() {
		var a = [{
			xtype: "container",
			layout: {
				type: "vbox",
				align: "stretch"
			},
			width: "100%",
			border: 0,
			items: [{
				xtype: "panel",
				layout: {
					type: "column"
				},
				border: 0,
				style: {
					padding: "10px",
					marginRight: "0px"
				},
				items: [{
					xtype: "panel",
					border: 0,
					baseCls: "float_right_panel",
					items: [{
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.soNumber"),
						labelAlign: "top",
						name: "soNumberField",
						idProperty: "soNumberField",
						id: "soNumberField",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "panel",
						layout: {
							type: "vbox"
						},
						id: "painelButtons",
						baseCls: "float_right_panel",
						style: {
							marginLeft: "15px"
						},
						border: 0,
						items: [{
							xtype: "button",
							id: "filter",
							text: bundle.getMsg("socontrol.filter"),
							action: "shopOrderCloseFilter",
							iconCls: "filterButtonIcon"
						}, {
							xtype: "tbspacer",
							height: 5
						}, {
							xtype: "button",
							id: "clear",
							text: bundle.getMsg("socontrol.clear"),
							action: "shopOrderCloseClear",
							iconCls: "clearButtonIcon"
						}]
					}]
				}]
			}]
		}];
		return a
	}
});
Ext.define("SO.view.ShopOrderRelease.ShopOrderCloseList", {
	extend: Ext.grid.Panel,
	alias: "widget.shopordercloselist",
	id: "shopordercloselist",
	autoWidth: true,
	autoHeight: true,
	initComponent: function() {
		var a = this;
		a.border = 0;
		a.stripeRows = false;
		a.store = Ext.getStore("ShopOrderCloseStore");
		a.selModel = Ext.create("Ext.selection.CheckboxModel", {
			mode: "MULTI",
			listeners: {
				scope: this,
				selectionchange: this.onSelectionChange
			}
		});
		a.columns = a.buildColumns();
		a.tbar = a.buildDockedItemsBar();
		a.dockedItems = a.buildFilterTopBar();
		a.bbar = a.buildPagingBottomBar();
		a.on({
			afterrender: function() {
				checkPermissionsByContainer(a)
			}
		});
		a.callParent(arguments)
	},
	onSelectionChange: function(d, b) {
		var a = b[0];
		var c = Ext.getCmp("closeshoporders");
		c.setDisabled(true);
		if (a) {
			c.setDisabled(false)
		}
	},
	buildColumns: function() {
		var a = [];
		a = [{
			header: bundle.getMsg("socontrol.soNumber"),
			dataIndex: "shopOrderNumber",
			flex: 1,
			sortable: true
		}];
		return a
	},
	buildFilterTopBar: function() {
		var a;
		a = Ext.create("SO.view.ShopOrderRelease.ShopOrderCloseFilter", {});
		return a
	},
	buildPagingBottomBar: function() {
		var a;
		a = Ext.create("Ext.Custom.CustomPaging", {
			store: Ext.getStore("ShopOrderCloseStore"),
			displayInfo: false,
			beforePageText: bundle.getMsg("socontrol.page"),
			afterPageText: ""
		});
		a.add("->");
		a.add({
			tooltip: bundle.getMsg("button.back"),
			text: bundle.getMsg("button.back"),
			scope: this,
			action: "backShopOrderReleaseBottom",
			id: "backShopOrderReleaseBottom"
		});
		return a
	},
	buildDockedItemsBar: function() {
		var a;
		a = Ext.create("Ext.toolbar.Toolbar", {
			items: [{
				id: "closeshoporders",
				action: "closeshoporders",
				actionKey: "shopOrder.shopOrderRelease.closeShopOrder.closeShopOrder",
				text: "Close Shop Orders",
				tooltip: "Close Shop Orders",
				iconCls: "releaseClose",
				disabled: true,
				scope: this
			}]
		});
		return a
	}
});
Ext.define("SO.view.ShopOrderRelease.OtherMappingsAvailableWindow", {
	extend: Ext.window.Window,
	alias: "widget.othermappingsavailablewindow",
	width: 684,
	height: 380,
	id: "othermappingsavailablewindow",
	model: true,
	constrain: true,
	renderTo: "xmain",
	initComponent: function(b) {
		var a = this;
		a.items = a.buildPanel();
		a.title = bundle.getMsg("socontrol.release.mapping.title.othermappingsavailablewindow");
		a.border = 0;
		a.modal = true;
		a.layout = {
			type: "hbox",
			align: "center"
		};
		this.callParent(b)
	},
	buildPanel: function() {
		var c = Ext.create("Ext.grid.Panel", {
			id: "othermappinggrid",
			style: {
				marginTop: "10px",
				marginLeft: "6px"
			},
			hideHeaders: true,
			multiSelect: true,
			columns: [{
				width: 110,
				flex: 1,
				sortable: true,
				dataIndex: "opMapKey",
				renderer: function(j, g, f, k, i, h, e) {
					return "<B>Mapping #" + j + "</B>"
				}
			}],
			stripeRows: true,
			title: bundle.getMsg("socontrol.results"),
			margins: "0 2 0 0",
			height: 300,
			width: 325
		});
		var a = function(j, g, f, k, i, h, e) {
				if (f.get("invalid")) {
					g.tdCls = " invalidBackground"
				}
				return j
			};
		var b = Ext.create("Ext.grid.Panel", {
			style: {
				marginTop: "10px",
				marginLeft: "10px"
			},
			id: "mappingsAvailable",
			columns: [{
				header: bundle.getMsg("socontrol.release.mapping.operationSequence"),
				width: 110,
				flex: 1,
				sortable: true,
				dataIndex: "mapOpSeq",
				renderer: a
			}, {
				xtype: "actioncolumn",
				width: 20,
				icon: path + "resources/images/16X16/map.png",
				renderer: a
			}, {
				header: bundle.getMsg("socontrol.release.mapping.locationProcessName"),
				width: 120,
				flex: 1,
				sortable: true,
				dataIndex: "locProcText",
				renderer: a
			}],
			stripeRows: true,
			title: bundle.getMsg("socontrol.selected"),
			margins: "0 0 0 3",
			height: 300,
			width: 325
		});
		var d = Ext.create("Ext.panel.Panel", {
			width: 674,
			height: 350,
			layout: "column",
			defaults: {
				flex: 1
			},
			items: [c, b],
			dockedItems: {
				xtype: "toolbar",
				dock: "bottom",
				items: ["->",
				{
					xtype: "button",
					text: bundle.getMsg("socontrol.ok"),
					action: "onOkOtherMappingsAvailable"
				}, {
					xtype: "button",
					text: bundle.getMsg("socontrol.cancel"),
					action: "onCancelOtherMappingsAvailable"
				}]
			}
		});
		return d
	}
});
Ext.define("SO.view.ShopOrderRelease.ReleaseShopOrderWindow", {
	extend: Ext.window.Window,
	alias: "widget.releaseshoporderwindow",
	width: 684,
	height: 480,
	id: "releaseshoporderwindow",
	model: true,
	constrain: true,
	renderTo: "xmain",
	initComponent: function(b) {
		var a = this;
		a.title = bundle.getMsg("socontrol.release.mapping.title.othermappingsavailablewindow");
		a.items = a.buildPanel();
		a.border = 0;
		a.modal = true;
		a.layout = {
			type: "hbox",
			align: "center"
		};
		this.callParent(b)
	},
	buildPanel: function() {
		var b = Ext.create("Ext.grid.Panel", {
			style: {
				marginTop: "10px",
				marginLeft: "6px"
			},
			id: "results",
			hideHeaders: true,
			multiSelect: true,
			listeners: {
				itemclick: this.itemClickShowMappings
			},
			columns: [{
				width: 110,
				flex: 1,
				sortable: true,
				dataIndex: "itemMapping"
			}],
			stripeRows: true,
			title: bundle.getMsg("socontrol.results"),
			margins: "0 2 0 0",
			height: 300,
			width: 325
		});
		var a = Ext.create("Ext.grid.Panel", {
			style: {
				marginTop: "10px",
				marginLeft: "10px"
			},
			id: "mappingsAvailable",
			columns: [{
				header: bundle.getMsg("socontrol.serialNumber"),
				width: 110,
				flex: 1,
				sortable: true,
				dataIndex: "serialNumber"
			}, {
				header: bundle.getMsg("socontrol.unitStatusKey"),
				width: 40,
				sortable: true,
				dataIndex: "unitStatusKey"
			}, {
				header: bundle.getMsg("socontrol.location"),
				width: 120,
				flex: 1,
				sortable: true,
				dataIndex: "location"
			}],
			stripeRows: true,
			title: bundle.getMsg("socontrol.selected"),
			margins: "0 0 0 3",
			height: 300,
			width: 325
		});
		var c = Ext.create("Ext.panel.Panel", {
			width: 674,
			height: 350,
			layout: "column",
			defaults: {
				flex: 1
			},
			items: [b, a],
			dockedItems: {
				xtype: "toolbar",
				dock: "bottom",
				items: ["->",
				{
					xtype: "button",
					text: bundle.getMsg("socontrol.ok"),
					action: "onOk"
				}, {
					xtype: "button",
					text: bundle.getMsg("socontrol.cancel"),
					action: "onCancel"
				}]
			}
		});
		return c
	}
});
Ext.define("SO.store.OperationSequenceStore", {
	extend: Ext.data.Store,
	model: "SO.model.OperationSequence",
	pageSize: 50,
	remoteSort: false,
	remoteFilter: false,
	autoLoad: false
});
Ext.define("SO.view.util.LocationUtil", {
	statics: {
		onChangeColorStatus: function(b, a) {
			var c = "rowSoBlack";
			if (b == 20 && a == "") {
				c = "rowOrange"
			} else {
				if (b == 20 && a != "") {
					c = "rowSoGreen"
				} else {
					if (b == 25) {
						c = "rowSoRed"
					} else {
						if (b == 26) {
							c = "rowViridian"
						} else {
							if (b == 27) {
								c = "rowBurgundy"
							} else {
								if (b == 28 && a == "") {
									c = "rowBoldGreen"
								} else {
									if (b == 28 && a != "") {
										c = "rowBoldOrange"
									} else {
										if (b == 29) {
											c = "rowBoldRed"
										} else {
											if (b == 30) {
												c = "rowBlue"
											} else {
												if (b == 50) {
													c = "rowGray"
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			return c
		}
	}
});
Ext.define("SO.view.ShopOrderRelease.ShopOrderMapping", {
	extend: Ext.panel.Panel,
	alias: "widget.shopordermapping",
	id: "shopordermapping",
	autoScroll: true,
	model: true,
	constrain: true,
	renderTo: "xmain",
	layout: "fit",
	autoHeight: true,
	autoWidth: true,
	viewOnly: false,
	initComponent: function(b) {
		var a = this;
		a.title = bundle.getMsg("socontrol.shopOrderMapping");
		a.items = a.buildPanel();
		a.dockedItems = a.buildDockedItems();
		a.border = 0;
		a.on({
			afterrender: function() {
				checkPermissionsByContainer(a)
			}
		});
		this.callParent(b)
	},
	buildViewConfig: function() {
		var a = {
			getRowClass: function(b, f, e, d) {
				var c = SO.view.util.LocationUtil.onChangeColorStatus(b.data.unitStatusKey, b.data.processName);
				return c
			}
		};
		return a
	},
	buildDockedItems: function() {
		var b = this;
		var a = {
			xtype: "toolbar",
			dock: "bottom",
			items: ["->",
			{
				xtype: "button",
				text: bundle.getMsg("socontrol.save"),
				action: "onSaveShopOrderMapping",
				actionKey: "shopOrder.shopOrderRelease.mapShopOrder.saveMapping",
				hidden: b.viewOnly
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.cancel"),
				action: "onCancelShopOrderMapping"
			}]
		};
		return a
	},
	buildPanel: function() {
		var f = this;
		var b = Ext.create("Ext.form.Panel", {
			width: 250,
			border: 1,
			id: "shopOrderInformationPanel",
			padding: 3,
			autoWidth: true,
			autoHeight: true,
			layout: {
				type: "table",
				columns: 1
			},
			fieldDefaults: {
				labelClsExtra: "labelFieldDisplayCss",
				labelWidth: 150,
				labelAlign: "top",
				style: {
					marginTop: "5px",
					marginLeft: "10px",
					marginBottom: "8px",
					fontWeight: "bold"
				}
			},
			items: [{
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.soNumber"),
				name: "shopOrderNumber"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.partNumber"),
				name: "partNumberField"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.revisionTable"),
				name: "revision"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.quantityTable"),
				name: "quantity"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.status"),
				name: "shopOrderStatus",
				renderer: function(i) {
					if (i == "N") {
						return "Not Released"
					} else {
						if (i == "R") {
							return "Released"
						} else {
							if (i == "C") {
								return "Completed"
							} else {
								if (i == "X") {
									return "Canceled"
								}
							}
						}
					}
				}
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.release.oracleSO"),
				name: "oracleShopOrder",
				renderer: function(i) {
					if (i == "true") {
						return "Yes"
					} else {
						return "No"
					}
				}
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.orgCode"),
				name: "organizationCode"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.projCode"),
				name: "projectCode"
			}, {
				xtype: "container",
				border: 0,
				layout: "hbox",
				items: [{
					xtype: "container",
					border: 0,
					layout: "vbox",
					items: [{
						xtype: "label",
						text: bundle.getMsg("socontrol.release.mapping.mappingType"),
						labelClsExtra: "labelFieldDisplayCss",
						labelWidth: 250,
						labelAlign: "top",
						style: {
							marginTop: "5px",
							marginLeft: "10px",
							fontWeight: "bold"
						}
					}, {
						xtype: "displayfield",
						name: "mappingTypeLabel",
						id: "mappingTypeLabel",
						style: {
							marginLeft: "10px",
							marginBottom: "15px"
						}
					}]
				}, {
					xtype: "button",
					icon: path + "resources/images/16X16/changeMappingType.png",
					tooltip: bundle.getMsg("socontrol.release.mapping.changeMappingType"),
					id: "changeMappingType2",
					action: "changeMappingType",
					actionKey: "shopOrder.shopOrderRelease.mapShopOrder.changeMappingType",
					scope: this,
					align: "top",
					hidden: f.viewOnly,
					cls: "",
					style: {
						"margin-top": "3px",
						"min-width": "30px",
						background: "transparent",
						"background-color": "transparent",
						border: "none"
					},
					width: 30
				}]
			}]
		});
		var e = Ext.create("Ext.grid.Panel", {
			hideHeaders: true,
			stripeRows: true,
			flex: 1,
			id: "operationSequence",
			multiSelect: true,
			columns: [{
				width: 110,
				flex: 1,
				sortable: true,
				dataIndex: "description",
				renderer: function(n, k, j, o, m, l, i) {
					return j.toStringForOpSeqGrid()
				}
			}, {
				hidden: true,
				dataIndex: "opseq"
			}],
			listeners: {
				itemclick: function(j, i, m, k, n, l) {
					if (k != -1 && !f.viewOnly) {
						Ext.getCmp("mappedOperationSequence").getSelectionModel().deselectAll()
					}
				}
			},
			tbar: Ext.create("Ext.toolbar.Toolbar", {
				items: [{
					xtype: "label",
					forId: "available",
					text: bundle.getMsg("socontrol.release.mapping.operationSequence"),
					cls: "labelFieldDisplayCss"
				}, "->",
				{
					xtype: "customtextfield",
					labelAlign: "right",
					width: 110,
					name: "filteropseq",
					action: "filteropseq",
					id: "findSNByTypeOperationSequence",
					enableKeyEvents: !f.viewOnly
				}]
			})
		});
		var d = Ext.create("Ext.grid.Panel", {
			hideHeaders: true,
			flex: 1,
			stripeRows: true,
			border: 1,
			style: {
				marginLeft: "3px"
			},
			id: "locationProcess",
			columns: [{
				width: 120,
				flex: 1,
				sortable: true,
				dataIndex: "name",
				renderer: function(n, k, j, o, m, l, i) {
					return "<b>" + n + "</b><br>" + j.get("sfdcId")
				}
			}],
			listeners: {
				itemclick: function(j, i, n, k, o, l) {
					if (k != -1 && !f.viewOnly) {
						var m = Ext.getCmp("mappedOperationSequence");
						m.getSelectionModel().deselectAll()
					}
				}
			},
			tbar: Ext.create("Ext.toolbar.Toolbar", {
				items: [{
					xtype: "label",
					forId: "available",
					text: bundle.getMsg("socontrol.release.mapping.locationProcessName"),
					cls: "labelFieldDisplayCss"
				}, "->",
				{
					xtype: "customtextfield",
					labelAlign: "right",
					width: 110,
					name: "filteropseq",
					action: "filteropseq",
					id: "findSNByTypeLocationProcess",
					enableKeyEvents: !f.viewOnly
				}]
			}),
			viewConfig: this.buildViewConfig()
		});
		var a = Ext.create("Ext.grid.Panel", {
			id: "mappedOperationSequence",
			stripeRows: true,
			title: bundle.getMsg("socontrol.release.mapping.mappedOperationSequence"),
			tbar: Ext.create("Ext.toolbar.Toolbar", {
				items: [{
					icon: path + "resources/images/16X16/remove.png",
					text: bundle.getMsg("socontrol.remove"),
					id: "removeToolbar",
					action: "onRemoveShopOrderMapping",
					actionKey: "shopOrder.shopOrderRelease.mapShopOrder.RemoveMappedOperationSequences",
					scope: this,
					disabled: true,
					hidden: f.viewOnly
				}, {
					icon: path + "resources/images/16X16/map.png",
					id: "automaticMap",
					text: bundle.getMsg("socontrol.release.mapping.automaticMap"),
					action: "automaticMap",
					actionKey: "shopOrder.shopOrderRelease.mapShopOrder.automaticMap",
					scope: this,
					hidden: f.viewOnly
				}, {
					icon: path + "resources/images/16X16/otherMappings.png",
					id: "otherMappingsAvailable",
					text: bundle.getMsg("socontrol.release.mapping.mappingsAvailable"),
					action: "otherMappingsAvailable",
					actionKey: "shopOrder.shopOrderRelease.mapShopOrder.mappingsAvailableMap",
					scope: this,
					hidden: f.viewOnly
				}]
			}),
			selModel: Ext.create("Ext.selection.CheckboxModel", {
				mode: "SINGLE",
				listeners: {
					selectionchange: function(j, i) {
						if (i[0] != null && !f.viewOnly) {
							Ext.getCmp("removeToolbar").setDisabled(false)
						} else {
							Ext.getCmp("removeToolbar").setDisabled(true)
						}
					}
				}
			}),
			columns: [{
				header: bundle.getMsg("socontrol.release.mapping.operationSequence"),
				width: 110,
				flex: 1,
				sortable: false,
				dataIndex: "mapOpSeq",
				renderer: function(o, k, j, p, n, m, i) {
					var l;
					Ext.getCmp("operationSequence").store.getRange().forEach(function(q) {
						if (q.data.opseq == o) {
							l = q
						}
					});
					if (j.get("invalid")) {
						k.tdCls = " invalidBackground"
					}
					return l ? l.toStringForMapping() : o
				}
			}, {
				xtype: "actioncolumn",
				width: 20,
				icon: path + "resources/images/16X16/map.png",
				renderer: function(n, k, j, o, m, l, i) {
					if (j.get("invalid")) {
						k.tdCls = " invalidBackground"
					}
					return n
				}
			}, {
				header: bundle.getMsg("socontrol.release.mapping.locationProcessName"),
				width: 120,
				flex: 1,
				sortable: false,
				dataIndex: "locProc",
				renderer: function(k, j, m, n, q, p, o) {
					var i = "";
					var l = "rowSoBlack";
					Ext.getCmp("locationProcess").store.getRange().forEach(function(s) {
						if (typeof(s.data.locationKey) != "undefined") {
							if (s.data.locationKey == k) {
								i = s.data.name;
								l = SO.view.util.LocationUtil.onChangeColorStatus(s.data.unitStatusKey, s.data.processName)
							}
						} else {
							if (s.data.name == k) {
								i = k
							}
						}
					});
					if (i == "") {
						i = m.get("locProcText")
					}
					if (m.get("invalid")) {
						l += " invalidBackground"
					}
					j.tdCls = l;
					return i
				}
			}],
			listeners: {
				itemclick: function(j, i, m, k, n, l) {
					if (k != -1 && !f.viewOnly) {
						Ext.getCmp("operationSequence").store.getRange().forEach(function(o) {
							if (o.data.opseq == i.data.mapOpSeq) {
								Ext.getCmp("operationSequence").getSelectionModel().select(o)
							}
						});
						Ext.getCmp("locationProcess").store.getRange().forEach(function(o) {
							if (i.data.mapTypeKey == 1) {
								if (o.data.name == i.data.locProc) {
									Ext.getCmp("locationProcess").getSelectionModel().select(o)
								}
							} else {
								if (i.data.mapTypeKey == 2) {
									if (o.data.locationKey == i.data.locProc) {
										Ext.getCmp("locationProcess").getSelectionModel().select(o)
									}
								}
							}
						})
					}
				}
			}
		});
		var h = Ext.create("Ext.panel.Panel", {
			autoWidth: true,
			autoHeight: true,
			border: 0,
			dockedItems: {
				xtype: "toolbar",
				dock: "bottom",
				items: ["->",
				{
					xtype: "button",
					text: bundle.getMsg("socontrol.release.mapping.addMap"),
					action: "addMap",
					actionKey: "shopOrder.shopOrderRelease.mapShopOrder.addMap",
					icon: path + "resources/images/16X16/add.png",
					hidden: f.viewOnly
				}]
			},
			layout: {
				type: "hbox",
				align: "stretch",
				padding: "0 3 3 0"
			},
			items: [e, d]
		});
		var g = Ext.create("Ext.container.Container", {
			autoWidth: true,
			autoHeight: true,
			flex: 1,
			defaults: {
				flex: 1
			},
			layout: {
				type: "vbox",
				align: "stretch",
				padding: "3 3 3 3"
			},
			items: [h, a]
		});
		var c = Ext.create("Ext.container.Container", {
			autoWidth: true,
			autoHeight: true,
			layout: {
				type: "hbox",
				align: "stretch",
				padding: "3 3 3 3"
			},
			items: [b, g]
		});
		return c
	}
});
Ext.define("SO.view.ReleaseShopOrder.QuantityStep", {
	extend: Ext.form.Panel,
	alias: "widget.quantitystep",
	itemId: "quantitystep",
	id: "quantitystep",
	layout: "fit",
	height: "100%",
	border: 0,
	initComponent: function() {
		this.tbar = {
			xtype: "label",
			text: "Release Type"
		};
		this.items = [{
			xtype: "panel",
			height: "100%",
			padding: "15 0 0 0",
			border: 0,
			layout: {
				type: "vbox",
				align: "stretch"
			},
			bodyStyle: "background:transparent;",
			items: [{
				xtype: "label",
				text: bundle.getMsg("socontrol.release.wizard.releaseQuantityStep.description")
			}, {
				xtype: "box",
				flex: 1
			}, {
				xtype: "panel",
				border: 0,
				layout: {
					type: "vbox",
					align: "center"
				},
				bodyStyle: "background:transparent;",
				items: [{
					xtype: "panel",
					border: 0,
					items: [{
						xtype: "radiofield",
						boxLabel: bundle.getMsg("socontrol.release.wizard.releaseQuantityStep.fullRelease"),
						name: "fullPartialReleaseType",
						inputValue: true,
						id: "fullReleaseType",
						checked: true
					}, {
						xtype: "radiofield",
						boxLabel: bundle.getMsg("socontrol.release.wizard.releaseQuantityStep.partialRelease"),
						name: "fullPartialReleaseType",
						inputValue: false,
						id: "partialReleaseType"
					}, {
						xtype: "numberfield",
						fieldLabel: bundle.getMsg("socontrol.quantityTable"),
						labelAlign: "top",
						id: "quantityPartialReleaseType",
						disabled: true,
						allowBlank: false,
						minValue: 1,
						maxValue: this.getMaxQuantity(),
						width: 280
					}]
				}]
			}, {
				xtype: "box",
				flex: 1
			}]
		}];
		this.callParent(arguments)
	},
	getMaxQuantity: function() {
		var a = Ext.getCmp("releasewindow").shopOrder;
		if (a == null) {
			return
		}
		var b = a.data;
		return b.increasedQuantity > 0 ? b.increasedQuantity : b.quantity
	}
});
Ext.define("SO.view.ReleaseShopOrder.SetupRevisionStep", {
	extend: Ext.form.Panel,
	alias: "widget.setuprevisionstep",
	itemId: "setuprevisionstep",
	id: "setuprevisionstep",
	layout: "fit",
	height: "100%",
	border: 0,
	partKey: null,
	revisionDefault: null,
	initComponent: function() {
		this.tbar = {
			xtype: "label",
			text: bundle.getMsg("socontrol.release.wizard.setupRevTitle")
		};
		this.items = {
			xtype: "panel",
			id: "panelWithComboAndTxt",
			xtype: "panel",
			border: 0,
			bodyStyle: "background:transparent;",
			layout: {
				type: "vbox",
				pack: "center",
				align: "center"
			}
		};
		this.on({
			scope: this,
			added: function() {
				this.reloadComponent()
			}
		});
		this.callParent(arguments)
	},
	reloadComponent: function() {
		var c = this,
			b = c.getRevisions(),
			a = Ext.getCmp("panelWithComboAndTxt");
		if (a.items.length == 0) {
			b.load({
				callback: function() {
					c.addRevisionField(b, a)
				}
			})
		}
	},
	getRevisions: function() {
		var a = Ext.create("Ext.data.Store", {
			scope: this,
			fields: ["revision"],
			autoLoad: false,
			proxy: {
				type: "ajax",
				format: "json",
				url: window.windowSOContext.ajaxURL,
				extraParams: {
					resourceID: "ShopOrderReleaseController.findAllPartRevisions",
					partKey: releaseWizardModel.get("shopOrder").getPartNumber().get("id")
				},
				reader: {
					root: "data"
				}
			}
		});
		return a
	},
	addRevisionField: function(b, a) {
		var c = this,
			d;
		if (b.getCount() == 0) {
			d = Ext.create("Ext.Custom.CustomTextField", {
				fieldLabel: bundle.getMsg("socontrol.release.wizard.setupRevisionStep.label"),
				labelAlign: "top",
				id: "revisionValue",
				width: 280,
				maxLength: 20,
				enableKeyEvents: true,
				maskRe: /[0-9a-zA-Z .-]/,
				value: releaseWizardModel.get("shopOrder").data.revision
			})
		} else {
			d = Ext.create("Ext.form.field.ComboBox", {
				xtype: "combobox",
				fieldLabel: bundle.getMsg("socontrol.release.wizard.setupRevisionStep.label"),
				labelAlign: "top",
				id: "revisionValue",
				forceSelection: true,
				width: 280,
				editable: false,
				displayField: "revision",
				valueField: "revision",
				store: b,
				queryMode: "local",
				listeners: {
					afterrender: function(e) {
						if (releaseWizardModel.get("shopOrder").data.revision != null && releaseWizardModel.get("shopOrder").data.revision != "") {
							if (!b.findRecord("revision", releaseWizardModel.get("shopOrder").data.revision)) {
								b.insert(0, {
									revision: releaseWizardModel.get("shopOrder").data.revision
								})
							}
							e.setValue(releaseWizardModel.get("shopOrder").get("revision"))
						}
					}
				}
			})
		}
		if (typeof(d) != "undefined") {
			a.add(d)
		}
	}
});
Ext.define("SO.view.ReleaseShopOrder.StepsPanel", {
	extend: Ext.panel.Panel,
	alias: "widget.stepspanel",
	id: "stepspanel",
	layout: "card",
	deferredRender: true,
	defaults: {
		padding: 10
	}
});
Ext.define("SO.view.ReleaseShopOrder.SetupSalesOrderLineStep", {
	extend: Ext.form.Panel,
	alias: "widget.setupsalesorderlinestep",
	itemId: "setupsalesorderlinestep",
	id: "setupsalesorderlinestep",
	layout: "fit",
	height: "100%",
	border: 0,
	initComponent: function() {
		var b = this;
		var a = Ext.create("Ext.data.Store", {
			model: "SO.model.SalesOrderLineModel",
			autoLoad: true,
			proxy: {
				type: "ajax",
				format: "json",
				url: window.windowSOContext.ajaxURL,
				extraParams: {
					resourceID: "ShopOrderReleaseController.findOrderLineByPart",
					partKey: releaseWizardModel.get("shopOrder").getPartNumber().get("id")
				},
				reader: {
					root: "data",
					totalProperty: "totalCount"
				}
			}
		});
		this.tbar = {
			xtype: "label",
			text: bundle.getMsg("socontrol.release.wizard.setupSalesOrderTitle")
		};
		this.items = {
			xtype: "panel",
			height: "100%",
			border: 0,
			layout: {
				type: "vbox",
				pack: "center",
				align: "center"
			},
			bodyStyle: "background:transparent;",
			items: [{
				flex: 1,
				xtype: "box"
			}, {
				xtype: "combobox",
				fieldLabel: bundle.getMsg("socontrol.release.wizard.setupSalesOrderLineStep.selectOrderLine"),
				labelAlign: "top",
				width: 280,
				id: "selectSalesOrder",
				name: "selectSalesOrder",
				idProperty: "selectSalesOrder",
				forceSelection: true,
				allowBlank: true,
				valueField: "key",
				displayField: "salesOrderNumber",
				validator: b.orderLineComboValidator,
				editable: true,
				store: a,
				queryMode: "local",
				tpl: Ext.create("Ext.XTemplate", '<tpl for=".">', '<div class="x-boundlist-item">', '<span style="font-weight:bold">{[values.salesOrderNumber]}</span><br/>', '<span style="font-size:75%;font-style:italic">{[values.orderLine]}</span>', "</div>", "</tpl>"),
				listeners: {
					select: function(e, c, d) {
						b.validationResult(e, c, d)
					}
				}
			}, {
				flex: 1,
				xtype: "box"
			}, {
				id: "salesOrderMessageField",
				border: 0,
				html: "",
				valid: true
			}]
		};
		this.on({
			added: function() {
				a.on({
					load: function(e, d, g, f) {
						var c = Ext.getCmp("releasewindow");
						if (!c) {
							return
						}
						Ext.Ajax.request({
							scope: this,
							url: window.windowSOContext.ajaxURL,
							method: "GET",
							format: "json",
							params: {
								resourceID: "ShopOrderReleaseController.findLastOrderLineAssignedToSerial",
								soKey: releaseWizardModel.get("shopOrder").get("id")
							},
							success: function(h) {
								var j = Ext.decode(h.responseText),
									i = Ext.getCmp("selectSalesOrder");
								if (typeof(j) != "undefined" && typeof(i) != "undefined") {
									i.canExceedsQty = j.canExceedsQty;
									i.select(j.lineKey)
								}
							}
						});
						if (d.length < 1) {
							b.showNoOrderLineError()
						} else {
							b.updateMsgField("", true)
						}
					}
				});
				a.load()
			}
		});
		this.callParent(arguments)
	},
	updateMsgField: function(c, d) {
		var a = Ext.getCmp("salesOrderMessageField"),
			b = Ext.get("salesOrderMessageField-body");
		a.valid = d;
		b.dom.innerHTML = c;
		a.doLayout()
	},
	validationResult: function(g, c, e) {
		if (c == null || c.length < 1 || c[0] == null) {
			return
		}
		var a = c[0],
			b = "",
			f = true,
			d = releaseWizardModel.get("quantity") > 0 ? releaseWizardModel.get("quantity") : releaseWizardModel.get("shopOrder").get("quantity") - releaseWizardModel.get("shopOrder").get("quantitySerial");
		if (g.store.getTotalCount() > 0) {
			if (a != undefined && (a.get("quantity") - a.get("unitsQty")) < d) {
				if (g.canExceedsQty) {
					b += "<li><img src='" + path + "resources/images/12X12/warning.png'/> " + bundle.getMsg("socontrol.salesOrderSnAssignment.label.line.exceedsQty") + "</li>"
				} else {
					b += "<li><img src='" + path + "resources/images/12X12/error.png'/> " + bundle.getMsg("socontrol.salesOrderSnAssignment.label.line.exceedsQty") + "</li>";
					f = false
				}
			}
		}
		this.updateMsgField(b, f);
		g.validate()
	},
	showNoOrderLineError: function() {
		var a = "";
		a += "<li><img src='" + path + "resources/images/12X12/warning.png'/> " + Ext.String.format(bundle.getMsg("socontrol.release.wizard.salesOrderNotFound"), releaseWizardModel.get("shopOrder").getPartNumber().get("partNumber")) + "</li>";
		this.updateMsgField(a, true)
	},
	orderLineComboValidator: function() {
		var a = Ext.getCmp("salesOrderMessageField");
		return a.valid ? true : bundle.getMsg("socontrol.salesOrderSnAssignment.label.line.exceedsQty")
	}
});
Ext.define("SO.view.ReleaseShopOrder.Step1Form", {
	extend: Ext.form.Panel,
	alias: "widget.step1form",
	itemId: "step1form",
	id: "step1form",
	layout: "fit",
	height: "100%",
	border: 0,
	initComponent: function() {
		this.tbar = {
			xtype: "label",
			text: "Welcome"
		};
		this.items = [{
			xtype: "panel",
			height: "100%",
			padding: "15 0 0 0",
			border: 0,
			layout: {
				type: "vbox",
				align: "stretch"
			},
			bodyStyle: "background:transparent;",
			items: [{
				xtype: "label",
				text: bundle.getMsg("socontrol.release.wizard.step1.welcomeMessage")
			}, {
				xtype: "box",
				flex: 1
			}, {
				xtype: "fieldcontainer",
				defaultType: "checkboxfield",
				items: this.getStep1Itens()
			}, {
				id: "step1MessageField",
				border: 0,
				html: this.updateWarnings()
			}]
		}, {
			xtype: "hiddenfield",
			id: "createSerial",
			value: this.getCreateSerialValue()
		}];
		this.callParent(arguments)
	},
	updateWarnings: function() {
		var a = releaseWizardModel.data.shopOrder;
		innerHtml = "";
		if (a.data.partHasRoute) {
			innerHtml += "<li><img src='" + path + "resources/images/12X12/warning.png'/> " + bundle.getMsg("validation.messages.noRouteAssignedToAssembly") + "</li>"
		}
		if (a.data.oracleShopOrder && a.data.mappingId == 0) {
			innerHtml += "<li><img src='" + path + "resources/images/12X12/warning.png'/> " + bundle.getMsg("validation.messages.soNotMapped") + "</li>"
		}
		if (a.data.mappingWarning) {
			innerHtml += "<li><img src='" + path + "resources/images/12X12/warning.png'/> " + bundle.getMsg("validation.messages.soMappedChanged") + "</li>"
		}
		if (a.data.algorithmName != null && a.data.algorithmName.indexOf("xAlgorithm") == 0) {
			innerHtml += "<li><img src='" + path + "resources/images/12X12/warning.png'/> " + bundle.getMsg("validation.messages.disabledAlgorithm") + "</li>"
		}
		return innerHtml
	},
	getStep1Itens: function() {
		var a = releaseWizardModel.data.shopOrder;
		if (a == null) {
			return
		}
		var b = new Array();
		if (a.data.revisionControlled == 1) {
			if (a.data.shopOrderStatus == "N") {
				b.push({
					boxLabel: bundle.getMsg("socontrol.release.wizard.step1.manuallyAssign"),
					name: "showRevisionStep",
					inputValue: "showRevisionStep",
					id: "showRevisionStep"
				})
			}
		}
		b.push({
			boxLabel: bundle.getMsg("socontrol.release.wizard.step1.defineUsl"),
			name: "defineUsl",
			inputValue: "defineUsl",
			id: "defineUsl"
		});
		b.push({
			boxLabel: bundle.getMsg("socontrol.release.wizard.step1.defineSalesOrder"),
			name: "defineSalesOrder",
			inputValue: "defineSalesOrder",
			id: "defineSalesOrder",
			visible: false
		});
		b.push({
			boxLabel: bundle.getMsg("socontrol.release.wizard.step1.createSkeleton"),
			name: "createSkeleton",
			inputValue: "createSkeleton",
			id: "createSkeleton"
		});
		if (!releaseWizardModel.get("auxiliaryRelease")) {
			b.push({
				boxLabel: bundle.getMsg("socontrol.release.wizard.step1.nonSerializedBath"),
				name: "nonSerializedBath",
				inputValue: "nonSerializedBath",
				id: "nonSerializedBath"
			})
		}
		return b
	},
	getCreateSerialValue: function() {
		var a = Ext.getCmp("releasewindow").shopOrder;
		if (a == null) {
			return false
		}
		if (a.data.algorithmNumber == null || a.data.algorithmNumber == 0) {
			return false
		} else {
			return true
		}
	}
});
Ext.define("SO.view.ReleaseShopOrder.StartSnStep", {
	extend: Ext.form.Panel,
	alias: "widget.startsnstep",
	itemId: "startsnstep",
	id: "startsnstep",
	layout: "fit",
	height: "100%",
	border: 0,
	initComponent: function() {
		this.tbar = {
			xtype: "label",
			text: "Start Serial Number"
		};
		this.callParent(arguments)
	},
	reloadComponent: function() {
		this.removeAll(true);
		this.add(this.getStartSnStepItems())
	},
	getAlgItems: function() {
		var b = new Array();
		var a = "";
		if (releaseWizardModel.get("startSerialAlgMaxWarning") && releaseWizardModel.get("startSerialAlgLatestWarning")) {
			if (releaseWizardModel.get("errorAction") != null && releaseWizardModel.get("errorAction") == "error.progress.socontrol.startSerialAlreadyExists") {
				b.push({
					xtype: "label",
					text: bundle.getMsg("error.progress.socontrol.startSerialAlreadyExists")
				});
				a = releaseWizardModel.get("byAlgorithmStartSerialNumberMax")
			} else {
				b.push({
					xtype: "label",
					html: Ext.String.format(bundle.getMsg("socontrol.release.wizard.releaseTypeStep.fail"), releaseWizardModel.get("byAlgorithmMax"), releaseWizardModel.get("byAlgorithmLatest"))
				})
			}
		} else {
			if (releaseWizardModel.get("startSerialAlgMaxWarning")) {
				b.push({
					xtype: "radiofield",
					boxLabel: Ext.String.format(bundle.getMsg("socontrol.release.errorStartingSerialNumber"), releaseWizardModel.get("byAlgorithmMax")),
					name: "algStartingType",
					inputValue: "max",
					id: "algStartingTypeMax",
					disabled: true
				})
			} else {
				b.push({
					xtype: "radiofield",
					boxLabel: (bundle.getMsg("socontrol.release.wizard.releaseTypeStep.max") + ": " + releaseWizardModel.get("byAlgorithmMax")),
					name: "algStartingType",
					inputValue: "max",
					id: "algStartingTypeMax",
					disabled: false,
					checked: releaseWizardModel.get("startSerialAlgLatestWarning")
				})
			}
			if (releaseWizardModel.get("startSerialAlgLatestWarning")) {
				b.push({
					xtype: "radiofield",
					boxLabel: Ext.String.format(bundle.getMsg("socontrol.release.errorStartingSerialNumber"), releaseWizardModel.get("byAlgorithmLatest")),
					name: "algStartingType",
					inputValue: "latest",
					id: "algStartingTypeLatest",
					disabled: true
				})
			} else {
				b.push({
					xtype: "radiofield",
					boxLabel: (bundle.getMsg("socontrol.release.wizard.releaseTypeStep.latest") + ": " + releaseWizardModel.get("byAlgorithmLatest")),
					name: "algStartingType",
					inputValue: "latest",
					id: "algStartingTypeLatest",
					disabled: false,
					checked: true
				})
			}
			if (!releaseWizardModel.get("startSerialAlgLatestWarning")) {
				a = releaseWizardModel.get("byAlgorithmStartSerialNumberLatest")
			} else {
				if (!releaseWizardModel.get("startSerialAlgMaxWarning")) {
					a = releaseWizardModel.get("byAlgorithmStartSerialNumberMax")
				}
			}
		}
		b.push({
			xtype: "customtextfield",
			fieldLabel: bundle.getMsg("socontrol.release.wizard.startingSerialNumber"),
			labelAlign: "top",
			width: 350,
			value: a,
			id: "algStartingSerialNumber",
			style: {
				marginTop: "6px"
			},
			allowBlank: false,
			maxLength: 50,
			regex: /^[^!@$][^@$]*$/
		});
		return b
	},
	getPartItems: function() {
		var b = new Array();
		var a = "";
		if (releaseWizardModel.get("startSerialPartMaxWarning") && releaseWizardModel.get("startSerialPartLatestWarning")) {
			if (releaseWizardModel.get("errorAction") != null && releaseWizardModel.get("errorAction") == "error.progress.socontrol.startSerialAlreadyExists") {
				b.push({
					xtype: "label",
					text: bundle.getMsg("error.progress.socontrol.startSerialAlreadyExists")
				});
				a = releaseWizardModel.get("byPartStartSerialNumberMax")
			} else {
				b.push({
					xtype: "label",
					text: Ext.String.format(bundle.getMsg("socontrol.release.wizard.releaseTypeStep.fail"), releaseWizardModel.get("byPartMax"), releaseWizardModel.get("byPartLatest"))
				})
			}
		} else {
			if (releaseWizardModel.get("startSerialPartMaxWarning")) {
				b.push({
					xtype: "radiofield",
					boxLabel: Ext.String.format(bundle.getMsg("socontrol.release.errorStartingSerialNumber"), releaseWizardModel.get("byPartStartSerialNumberMax")),
					name: "byPartStartSerialNumberMax",
					inputValue: "max",
					id: "partStartingTypeMax",
					disabled: true
				})
			} else {
				b.push({
					xtype: "radiofield",
					boxLabel: (bundle.getMsg("socontrol.release.wizard.releaseTypeStep.max") + ": " + releaseWizardModel.get("byPartStartSerialNumberMax")),
					name: "byPartStartSerialNumberMax",
					inputValue: "max",
					id: "partStartingTypeMax",
					disabled: false,
					checked: releaseWizardModel.get("startSerialPartLatestWarning")
				})
			}
			if (releaseWizardModel.get("startSerialPartLatestWarning")) {
				b.push({
					xtype: "radiofield",
					boxLabel: Ext.String.format(bundle.getMsg("socontrol.release.errorStartingSerialNumber"), releaseWizardModel.get("byPartStartSerialNumberLatest")),
					name: "byPartStartSerialNumberLatest",
					inputValue: "latest",
					id: "partStartingTypeLatest",
					disabled: true
				})
			} else {
				b.push({
					xtype: "radiofield",
					boxLabel: (bundle.getMsg("socontrol.release.wizard.releaseTypeStep.latest") + ": " + releaseWizardModel.get("byPartStartSerialNumberLatest")),
					name: "byPartStartSerialNumberLatest",
					inputValue: "latest",
					id: "partStartingTypeLatest",
					disabled: false,
					checked: true
				})
			}
			if (!releaseWizardModel.get("startSerialPartLatestWarning")) {
				a = releaseWizardModel.get("byPartStartSerialNumberLatest")
			} else {
				if (!releaseWizardModel.get("startSerialPartMaxWarning")) {
					a = releaseWizardModel.get("byPartStartSerialNumberMax")
				}
			}
		}
		b.push({
			xtype: "customtextfield",
			fieldLabel: bundle.getMsg("socontrol.release.wizard.startingSerialNumber"),
			labelAlign: "top",
			width: 350,
			value: a,
			id: "partStartingSerialNumber",
			style: {
				marginTop: "6px"
			},
			allowBlank: false,
			maxLength: 50,
			regex: /^[^!@$][^@$]*$/
		});
		return b
	},
	getStartSnStepItems: function() {
		var a = [{
			xtype: "panel",
			height: "100%",
			padding: "15 0 0 0",
			border: 0,
			layout: {
				type: "vbox",
				align: "stretch"
			},
			bodyStyle: "background:transparent;",
			items: [{
				xtype: "label",
				text: bundle.getMsg("socontrol.release.wizard.releaseTypeStep.selectType")
			}, {
				xtype: "box",
				flex: 1
			}, {
				xtype: "panel",
				border: 0,
				layout: {
					type: "column"
				},
				items: [{
					flex: 1,
					xtype: "radiofield",
					boxLabel: bundle.getMsg("socontrol.release.wizard.releaseTypeStep.byAlgorithm"),
					name: "releaseType",
					inputValue: "algorithmRT",
					id: "algorithmRT",
					checked: (releaseWizardModel.get("releaseType") == 1),
					width: "70px"
				}, {
					xtype: "panel",
					layout: "vbox",
					border: 0,
					id: "algorithmRTPanel",
					disabled: ((releaseWizardModel.get("releaseType") != 1)),
					items: this.getAlgItems()
				}, {
					xtype: "radiofield",
					boxLabel: bundle.getMsg("socontrol.release.wizard.releaseTypeStep.byPart"),
					labelAlign: "top",
					name: "releaseType",
					inputValue: "partNumberRT",
					id: "partNumberRT",
					checked: (releaseWizardModel.get("releaseType") == 0),
					width: "70px",
					style: {
						marginTop: "20px"
					}
				}, {
					xtype: "panel",
					layout: "vbox",
					id: "partNumberRTPanel",
					border: 0,
					style: {
						marginTop: "20px"
					},
					disabled: ((releaseWizardModel.get("releaseType") != 0)),
					items: this.getPartItems()
				}]
			}, {
				xtype: "box",
				flex: 1
			}]
		}];
		return a
	}
});
Ext.define("SO.view.ReleaseShopOrder.ErrorWarningStep", {
	extend: Ext.form.Panel,
	alias: "widget.errorwarningstep",
	itemId: "errorwarningstep",
	id: "errorwarningstep",
	height: "100%",
	layout: "fit",
	border: 0,
	typeMessage: "",
	errorWarningMessage: "",
	initComponent: function() {
		var a = this;
		a.items = [{
			xtype: "panel",
			height: "100%",
			border: 0,
			layout: {
				type: "vbox",
				align: "stretch"
			},
			items: [{
				id: "ErrorWarningType",
				html: "",
				border: 0,
				height: 60,
				style: {
					fontWeight: "bold"
				}
			}, {
				xtype: "label",
				text: bundle.getMsg("socontrol.release.wizard.errorDuringRelease"),
				width: "100%",
				style: {
					marginBottom: "10px"
				}
			}, {
				xtype: "box",
				id: "ErrorWarningMessage",
				autoScroll: true,
				flex: 1,
				height: 300,
				width: "100%",
				border: 1,
				style: {
					border: "1px solid red",
					background: "#FFEFD5",
					padding: "10px 10px 10px 10px"
				}
			}]
		}];
		a.callParent(arguments)
	},
	reloadComponent: function() {
		this.refreshScreen()
	},
	getType: function() {
		var a = "";
		if (this.typeMessage == "error") {
			a = "<img src='" + path + "resources/images/48X48/error.png'/><span class='fontSizeRelease'>" + bundle.getMsg("socontrol.message.error") + "</span>"
		} else {
			a = "<img src='" + path + "resources/images/48X48/warning.png'/><span class='fontSizeRelease'>" + bundle.getMsg("socontrol.message.warning") + "</span>"
		}
		return a
	},
	refreshScreen: function() {
		var a = Ext.get("ErrorWarningType-body");
		a.dom.innerHTML = this.getType();
		Ext.getCmp("ErrorWarningType").doLayout();
		Ext.getCmp("ErrorWarningMessage").update(this.errorWarningMessage)
	}
});
Ext.define("SO.view.ReleaseShopOrder.ReleaseWindow", {
	extend: Ext.Window,
	require: ["ReleaseShopOrder.StepsPanel"],
	alias: "widget.releasewindow",
	id: "releasewindow",
	layout: "fit",
	height: "100%",
	border: 0,
	width: 700,
	height: 500,
	modal: true,
	constrain: true,
	renderTo: "xmain",
	shopOrder: null,
	closable: false,
	locking: true,
	layout: "fit",
	defaults: {
		border: false,
		bodyPadding: 5
	},
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("socontrol.release.wizard.title");
		a.items = a.buildPanel();
		a.buttons = a.buildButtons();
		this.callParent(arguments)
	},
	buildButtons: function() {
		var a = [{
			id: "releasePreviousBtn",
			text: bundle.getMsg("button.previous"),
			action: "onPrevStep",
			nextStep: "",
			disabled: true
		}, {
			id: "releaseNextBtn",
			text: bundle.getMsg("button.next"),
			action: "onNextStep"
		}, {
			id: "releaseFinishBtn",
			text: bundle.getMsg("button.finish"),
			action: "onFinishReleaseWizard",
			disabled: true
		}, {
			id: "releaseCancelBtn",
			text: bundle.getMsg("socontrol.cancel"),
			action: "onCancelReleaseWizard"
		}];
		return a
	},
	buildPanel: function() {
		var a = Ext.create("Ext.form.Panel", {
			id: "soInfoPanel",
			width: 180,
			border: 1,
			style: {
				paddingRight: "4px"
			},
			defaultType: "displayfield",
			fieldDefaults: {
				labelWidth: 150,
				labelAlign: "top",
				labelCls: "labelFieldDisplayCss",
				style: {
					marginLeft: "5px",
					marginTop: "10px"
				}
			},
			items: [{
				fieldLabel: bundle.getMsg("socontrol.soNumber"),
				name: "shopOrderNumber"
			}, {
				fieldLabel: bundle.getMsg("socontrol.partNumber"),
				name: "partNumberString"
			}, {
				fieldLabel: bundle.getMsg("socontrol.release.wizard.revision"),
				name: "revision"
			}, {
				fieldLabel: bundle.getMsg("socontrol.quantityTable"),
				name: "quantity"
			}, {
				fieldLabel: bundle.getMsg("socontrol.boardsPerPanel"),
				name: "boardsPerPanel"
			}, {
				fieldLabel: bundle.getMsg("socontrol.release.increasedQty"),
				name: "increasedQuantity"
			}, {
				fieldLabel: bundle.getMsg("socontrol.release.startDate"),
				name: "startDate"
			}, {
				fieldLabel: bundle.getMsg("socontrol.release.algorithmName"),
				name: "algorithmName"
			}]
		});
		var b = Ext.create("Ext.panel.Panel", {
			layout: {
				type: "hbox",
				align: "stretch"
			},
			items: [a, Ext.create("SO.view.ReleaseShopOrder.StepsPanel", {
				flex: 1
			})]
		});
		return b
	}
});
Ext.define("SO.view.ReleaseShopOrder.SummaryStep", {
	extend: Ext.form.Panel,
	alias: "widget.summarystep",
	itemId: "summarystep",
	id: "summarystep",
	layout: "fit",
	height: "100%",
	border: 0,
	initComponent: function() {
		this.tbar = {
			xtype: "label",
			text: "Release Summary"
		};
		this.callParent(arguments)
	},
	reloadComponent: function() {
		this.removeAll(true);
		this.add(this.getSummaryStepItems())
	},
	getSummaryStepItems: function() {
		var a = {
			xtype: "panel",
			height: "100%",
			padding: "15 0 0 0",
			border: 0,
			layout: {
				type: "vbox",
				align: "stretch"
			},
			bodyStyle: "background:transparent;",
			items: [{
				xtype: "panel",
				layout: "column",
				border: false,
				defaultType: "panel",
				items: [{
					columnWidth: 0.5,
					defaultType: "displayfield",
					layout: "vbox",
					border: false,
					items: this.getShopOrderPanel()
				}, {
					columnWidth: 0.5,
					defaultType: "displayfield",
					border: false,
					layout: "vbox",
					items: this.getStartingSerialNumberPanel()
				}]
			}, {
				xtype: "box",
				flex: 1
			}, {
				xtype: "panel",
				border: false,
				items: this.getCheckBoxPanel()
			}]
		};
		return a
	},
	getShopOrderPanel: function() {
		var a = new Array();
		a.push({
			xtype: "label",
			text: bundle.getMsg("socontrol.release.wizard.shopOrder"),
			style: {
				paddingBottom: "10px",
				fontWeight: "bold"
			}
		});
		a.push({
			fieldLabel: bundle.getMsg("socontrol.release.wizard.shopOrderNumber"),
			value: releaseWizardModel.get("shopOrder").get("shopOrderNumber"),
			labelWidth: 150
		});
		a.push({
			fieldLabel: bundle.getMsg("socontrol.release.wizard.partNumber"),
			value: releaseWizardModel.get("shopOrder").getPartNumber().get("partNumber"),
			labelWidth: 150
		});
		a.push({
			fieldLabel: bundle.getMsg("socontrol.release.wizard.userDefined"),
			value: releaseWizardModel.get("shopOrder").get("userDefined"),
			labelWidth: 150
		});
		a.push({
			fieldLabel: bundle.getMsg("socontrol.release.wizard.revision"),
			value: releaseWizardModel.get("shopOrder").get("revision"),
			labelWidth: 150
		});
		a.push({
			fieldLabel: bundle.getMsg("socontrol.release.quantity"),
			value: releaseWizardModel.get("shopOrder").get("quantity"),
			labelWidth: 150
		});
		if (releaseWizardModel.get("auxiliaryRelease")) {
			a.push({
				fieldLabel: bundle.getMsg("socontrol.release.newPanelQuantity"),
				value: releaseWizardModel.get("panelQuantity"),
				labelWidth: 150
			})
		}
		a.push({
			fieldLabel: bundle.getMsg("socontrol.release.browser.increasedQuantity"),
			value: releaseWizardModel.get("shopOrder").get("increasedQuantity"),
			labelWidth: 150
		});
		a.push({
			fieldLabel: bundle.getMsg("socontrol.release.wizard.boardsPerPanel"),
			value: releaseWizardModel.get("shopOrder").get("boardsPerPanel"),
			labelWidth: 150
		});
		a.push({
			fieldLabel: bundle.getMsg("socontrol.release.wizard.snQtyToRelease"),
			value: (releaseWizardModel.get("fullRelease") ? bundle.getMsg("label.all") : releaseWizardModel.get("quantity")),
			labelWidth: 150
		});
		return a
	},
	getStartingSerialNumberPanel: function() {
		var a = new Array();
		a.push({
			xtype: "label",
			text: bundle.getMsg("socontrol.release.wizard.startingSerialNumber"),
			style: {
				paddingBottom: "10px",
				fontWeight: "bold"
			}
		});
		if (releaseWizardModel.get("createSerial")) {
			a.push({
				fieldLabel: bundle.getMsg("socontrol.release.wizard.summaryStep.algorithmName"),
				value: releaseWizardModel.get("algorithmName"),
				labelWidth: 150
			});
			a.push({
				fieldLabel: bundle.getMsg("socontrol.release.wizard.ssnType"),
				value: this.getSsnType(),
				labelWidth: 150
			});
			a.push({
				fieldLabel: bundle.getMsg("socontrol.release.wizard.startingSerialNumber"),
				value: releaseWizardModel.get("startSerialNumber"),
				labelWidth: 150
			});
			if (releaseWizardModel.get("releaseType") == 1) {
				a.push({
					fieldLabel: bundle.getMsg("socontrol.release.wizard.releaseTypeStep.latest"),
					value: releaseWizardModel.get("byAlgorithmLatest"),
					labelWidth: 150
				});
				a.push({
					fieldLabel: bundle.getMsg("socontrol.release.wizard.releaseTypeStep.max"),
					value: releaseWizardModel.get("byAlgorithmMax"),
					labelWidth: 150
				})
			} else {
				if (releaseWizardModel.get("releaseType") == 0) {
					a.push({
						fieldLabel: bundle.getMsg("socontrol.release.wizard.releaseTypeStep.latest"),
						value: releaseWizardModel.get("byPartLatest"),
						labelWidth: 150
					});
					a.push({
						fieldLabel: bundle.getMsg("socontrol.release.wizard.releaseTypeStep.max"),
						value: releaseWizardModel.get("byPartMax"),
						labelWidth: 150
					})
				} else {
					a.push({
						xtype: "label",
						text: bundle.getMsg("socontrol.release.wizard.releaseTypeStep.manuallyInfo"),
						width: 250
					})
				}
			}
		} else {
			if (releaseWizardModel.get("createSkeleton")) {
				a.push({
					xtype: "label",
					text: bundle.getMsg("socontrol.release.wizard.releaseTypeStep.skeletonSerial"),
					width: 250
				})
			} else {
				if (releaseWizardModel.get("batchRelease")) {
					a.push({
						xtype: "label",
						text: bundle.getMsg("socontrol.release.wizard.releaseTypeStep.isBatchRelease"),
						width: 250
					})
				} else {
					a.push({
						xtype: "label",
						text: bundle.getMsg("socontrol.release.wizard.releaseTypeStep.noSerial"),
						width: 250
					})
				}
			}
		}
		return a
	},
	getCheckBoxPanel: function() {
		var a = new Array();
		if (releaseWizardModel.get("shopOrder").get("oracleShopOrder")) {
			a.push({
				xtype: "checkboxfield",
				boxLabel: bundle.getMsg("socontrol.release.wizard.summaryStep.createAssembliesAutomatically"),
				name: "summaryStepOptions",
				inputValue: "createAssembliesAutomatically",
				id: "createAssembliesAutomatically",
				checked: releaseWizardModel.data.defaultOptions.search("create_assm") > -1
			})
		}
		a.push({
			xtype: "checkboxfield",
			boxLabel: bundle.getMsg("socontrol.release.wizard.summaryStep.printLabels"),
			name: "summaryStepOptions",
			inputValue: "printSerials",
			id: "printSerials",
			checked: releaseWizardModel.data.defaultOptions.search("print_label") > -1
		});
		a.push({
			xtype: "checkboxfield",
			boxLabel: bundle.getMsg("socontrol.release.wizard.summaryStep.createTextFile"),
			name: "summaryStepOptions",
			inputValue: "createSerialFile",
			id: "createSerialFile",
			checked: releaseWizardModel.data.defaultOptions.search("create_file") > -1
		});
		a.push({
			xtype: "checkboxfield",
			boxLabel: bundle.getMsg("socontrol.release.wizard.summaryStep.createNotes"),
			name: "summaryStepOptions",
			inputValue: "createNotes",
			id: "createNotes",
			checked: releaseWizardModel.data.defaultOptions.search("create_notes") > -1
		});
		if (this.canShowPrintTraveler()) {
			if (releaseWizardModel.get("oneTravelerPerUnit")) {
				a.push({
					xtype: "checkboxfield",
					boxLabel: bundle.getMsg("socontrol.release.wizard.summaryStep.printTraveler"),
					name: "printTravelerOptions",
					inputValue: "printTravelerOnePerUnit",
					id: "printTravelerOnePerUnit",
					checked: releaseWizardModel.data.defaultOptions.search("print_unit_trav") > -1
				})
			} else {
				if (releaseWizardModel.get("wipTravelerPerUnit")) {
					a.push({
						xtype: "checkboxfield",
						boxLabel: bundle.getMsg("socontrol.release.wizard.summaryStep.wipTravelerPerUnit"),
						name: "printTravelerOptions",
						inputValue: "printTravelerWip",
						id: "printTravelerWip",
						checked: releaseWizardModel.data.defaultOptions.search("print_wip_unit_trav") > -1
					})
				} else {
					a.push({
						xtype: "checkboxfield",
						boxLabel: bundle.getMsg("socontrol.release.wizard.summaryStep.printTravelerOnePerOrder"),
						name: "printTravelerOptions",
						inputValue: "printTravelerOnePerOrder",
						id: "printTravelerOnePerOrder",
						checked: releaseWizardModel.data.defaultOptions.search("print_order_trav") > -1
					})
				}
			}
		}
		if (releaseWizardModel.get("soLinkage")) {
			a.push({
				xtype: "checkboxfield",
				boxLabel: bundle.getMsg("socontrol.release.wizard.summaryStep.soLinkage"),
				name: "summaryStepOptions",
				inputValue: "soLinkage",
				id: "soLinkage",
				checked: releaseWizardModel.data.defaultOptions.search("link_so") > -1
			})
		}
		a.push({
			id: "printTravelerMessageField",
			border: 0,
			html: ""
		});
		return a
	},
	canShowPrintTraveler: function() {
		var a = false;
		if (!releaseWizardModel.get("releaseError") && !releaseWizardModel.get("createSkeleton") && true && (((releaseWizardModel.get("oneTravelerPerUnit") || releaseWizardModel.get("wipTravelerPerUnit")) && releaseWizardModel.get("shopOrder").get("oracleShopOrder") && releaseWizardModel.get("hasBOM")) || releaseWizardModel.get("oneTravelerPerOrder"))) {
			a = true
		}
		return a
	},
	getSsnType: function() {
		var a = "";
		if (releaseWizardModel.get("releaseType") == 1) {
			a = bundle.getMsg("socontrol.release.wizard.releaseTypeStep.byAlgorithm")
		} else {
			if (releaseWizardModel.get("releaseType") == 0) {
				a = bundle.getMsg("socontrol.release.wizard.releaseTypeStep.byPart")
			} else {
				a = bundle.getMsg("socontrol.release.wizard.releaseTypeStep.manually")
			}
		}
		return a
	}
});
Ext.define("SO.view.ReleaseShopOrder.ReleaseFailStep", {
	extend: Ext.form.Panel,
	alias: "widget.releasefailstep",
	itemId: "releasefailstep",
	id: "releasefailstep",
	layout: "fit",
	height: "100%",
	border: 0,
	errorMessage: "",
	initComponent: function() {
		var a = this;
		a.items = [{
			xtype: "panel",
			height: "100%",
			layout: {
				type: "vbox",
				align: "stretch"
			},
			border: 0,
			items: [{
				id: "ErrorType",
				html: "",
				border: 0,
				height: 60,
				style: {
					fontWeight: "bold"
				}
			}, {
				xtype: "label",
				text: bundle.getMsg("socontrol.release.wizard.errorDuringRelease"),
				width: "100%",
				style: {
					marginBottom: "10px"
				}
			}, {
				xtype: "box",
				id: "ErrorMessage",
				flex: 1,
				autoScroll: true,
				border: 1,
				style: {
					border: "1px solid red",
					background: "#FFEFD5",
					padding: "10px 10px 10px 10px"
				}
			}]
		}];
		a.callParent(arguments)
	},
	reloadComponent: function() {
		this.refreshScreen()
	},
	refreshScreen: function() {
		var a = Ext.get("ErrorType-body");
		a.dom.innerHTML = "<img src='" + path + "resources/images/48X48/error.png'/><span class='fontSizeRelease'>" + bundle.getMsg("socontrol.message.error") + "</span>";
		Ext.getCmp("ErrorType").doLayout();
		Ext.getCmp("ErrorMessage").update(this.errorMessage)
	}
});
Ext.define("SO.view.ReleaseShopOrder.AuxReleaseQtyStep", {
	extend: Ext.form.Panel,
	alias: "widget.auxreleaseqtystep",
	itemId: "auxreleaseqtystep",
	id: "auxreleaseqtystep",
	layout: "fit",
	height: "100%",
	border: 0,
	initComponent: function() {
		this.items = [{
			xtype: "panel",
			height: "100%",
			layout: "border",
			border: 0,
			bodyStyle: "background:transparent;",
			items: [{
				region: "north",
				xtype: "label",
				text: bundle.getMsg("socontrol.release.wizard.auxiliaryReleaseStep.description")
			}, {
				region: "center",
				xtype: "numberfield",
				fieldLabel: bundle.getMsg("socontrol.release.wizard.auxiliaryReleaseStep.quantity"),
				labelAlign: "top",
				id: "auxreleaseqty",
				disabled: false,
				allowBlank: false,
				minValue: 1,
				maxValue: this.getMaxQuantity()
			}]
		}];
		this.callParent(arguments)
	},
	getMaxQuantity: function() {
		var a = Ext.getCmp("releasewindow").shopOrder;
		var b = a.data;
		return 500000 - b.quantity
	}
});
Ext.define("SO.view.ReleaseShopOrder.GenericResultStep", {
	extend: Ext.panel.Panel,
	alias: "widget.genericresultstep",
	itemId: "genericresultstep",
	id: "genericresultstep",
	layout: "fit",
	height: "100%",
	border: 0,
	initComponent: function() {
		this.tbar = {
			xtype: "label",
			text: "Release Results"
		};
		this.callParent(arguments)
	},
	loadPartialReleaseResultCmp: function() {
		var a = bundle.getMsg("socontrol.release.wizard.partialReleaseStep.doPartialRelease"),
			b = bundle.getMsg("socontrol.release.wizard.partialReleaseStep.title");
		htmlBody = "<h1 class='h1style' >" + b + "</h1> <BR></BR> <p>" + a + "</p>";
		this.removeAll();
		this.add({
			xtype: "panel",
			html: htmlBody,
			height: "100%",
			padding: "15 0 0 0",
			border: 0
		})
	},
	loadReleaseResultCmp: function(b, c) {
		var a = "";
		if (c) {
			a = "<img src='" + path + "resources/images/12X12/warning.png'/> "
		}
		a = a + b;
		this.removeAll();
		this.add({
			xtype: "panel",
			html: a,
			height: "100%",
			padding: "15 0 0 0",
			border: 0
		})
	}
});
Ext.define("SO.view.ReleaseShopOrder.SetupUSLStep", {
	extend: Ext.form.Panel,
	alias: "widget.setupuslstep",
	itemId: "setupuslstep",
	id: "setupuslstep",
	layout: "fit",
	height: "100%",
	border: 0,
	initComponent: function() {
		this.tbar = {
			xtype: "label",
			text: bundle.getMsg("socontrol.release.wizard.setupUSLTitle")
		}, this.items = [{
			xtype: "panel",
			border: 0,
			bodyStyle: "background:transparent;",
			layout: {
				type: "vbox",
				pack: "center",
				align: "center"
			},
			items: [{
				xtype: "combobox",
				fieldLabel: bundle.getMsg("socontrol.release.wizard.setupUSLStep.selectLocation"),
				width: 280,
				labelAlign: "top",
				id: "unitStartedLocation",
				name: "unitStartedLocation",
				idProperty: "unitStartedLocation",
				valueField: "locationKey",
				displayField: "name",
				editable: true,
				forceSelection: true,
				queryMode: "local",
				tpl: Ext.create("Ext.XTemplate", '<tpl for=".">', '<div class="x-boundlist-item">', '<span style="font-weight:bold">{[this.formatName(values.name)]}</span><br/>', '<span style="font-size:75%;font-style:italic">{[this.formatDetails(values.name, values.sfdcId, values.status, values.unitStatusKey)]}</span>', "</div>", "</tpl>", {
					formatName: function(a) {
						return a.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;")
					},
					formatDetails: function(d, c, b, a) {
						var e = "";
						if (d != null && d != "") {
							e = c + " / " + bundle.getMsg("socontrol.status") + ":" + a
						}
						return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;")
					}
				}),
				displayTpl: Ext.create("Ext.XTemplate", '<tpl for=".">', "{name}", "</tpl>"),
				store: Ext.create("Ext.data.Store", {
					fields: ["locationKey", "name", "sfdcId", "unitStatusKey"],
					autoLoad: true,
					proxy: {
						type: "ajax",
						format: "json",
						url: window.windowSOContext.ajaxURL,
						extraParams: {
							resourceID: "ShopOrderReleaseController.findUsl"
						},
						reader: {
							root: "data",
							totalProperty: "totalCount"
						}
					}
				})
			}]
		}];
		this.callParent(arguments)
	}
});
Ext.define("SO.view.ReleaseShopOrder.ReleaseNotesStep", {
	extend: Ext.form.Panel,
	alias: "widget.releasenotesstep",
	itemId: "releasenotesstep",
	id: "releasenotesstep",
	layout: "fit",
	height: "100%",
	border: 0,
	initComponent: function() {
		this.tbar = {
			xtype: "label",
			text: bundle.getMsg("socontrol.releaseNotes")
		};
		this.items = [{
			xtype: "form",
			id: "releasenotesstepform",
			height: "100%",
			padding: "15 0 0 0",
			layout: "border",
			border: 0,
			bodyStyle: "background:transparent;",
			items: [{
				region: "center",
				xtype: "textarea",
				name: "notes",
				maxLength: 30000,
				disabled: false
			}, {
				region: "south",
				xtype: "panel",
				border: 0,
				layout: {
					type: "column"
				},
				items: [{
					xtype: "displayfield",
					fieldLabel: "Created By",
					labelWidth: 70,
					name: "createUser",
					columnWidth: 0.5
				}, {
					xtype: "displayfield",
					fieldLabel: "Date/Time",
					labelWidth: 70,
					name: "createDttm",
					columnWidth: 0.5
				}]
			}]
		}];
		this.callParent(arguments)
	}
});
Ext.define("SO.view.RecipeDisplay.SaveRecipeWindow", {
	extend: Ext.window.Window,
	alias: "widget.saverecipewindow",
	id: "saverecipewindow",
	resizable: false,
	modal: true,
	constrain: true,
	renderTo: "xmain",
	buildButtons: function() {
		var a = [{
			text: bundle.getMsg("socontrol.ok"),
			action: "saveRecipe"
		}, {
			text: bundle.getMsg("socontrol.cancel"),
			handler: function() {
				this.up("window").close()
			}
		}];
		return a
	},
	initComponent: function() {
		var a = this;
		a.items = a.buildPanel();
		a.title = bundle.getMsg("socontrol.browser.saveRecipe");
		a.buttons = a.buildButtons();
		a.border = 0;
		a.modal = true;
		a.layout = {
			type: "hbox",
			align: "center"
		};
		this.callParent(arguments)
	},
	buildPanel: function() {
		var a = Ext.create("Ext.form.Panel", {
			id: "saverecipeform",
			baseCls: "toolbarColor",
			width: 300,
			padding: "15 15 15 15",
			items: [{
				xtype: "customtextfield",
				fieldLabel: bundle.getMsg("socontrol.browser.deviationReference"),
				name: "devRef",
				id: "devRef",
				labelWidth: 120,
				allowBlank: false
			}, {
				xtype: "radiofield",
				boxLabel: bundle.getMsg("socontrol.release.soNumber"),
				name: "savetype",
				inputValue: "shoporder",
				id: "shoporderOption",
				checked: true
			}, {
				xtype: "radiofield",
				boxLabel: bundle.getMsg("nextgen.recipe.popup.saveRecipe.snNotComplete"),
				name: "savetype",
				inputValue: "serialnotcomplete",
				id: "serialnotcomplete"
			}, {
				xtype: "radiofield",
				boxLabel: bundle.getMsg("nextgen.recipe.popup.saveRecipe.snNotReleased"),
				name: "savetype",
				inputValue: "serialnotreleased",
				id: "serialnotreleased"
			}, {
				xtype: "radiofield",
				boxLabel: bundle.getMsg("socontrol.release.print.serialNumber"),
				name: "savetype",
				inputValue: "serialnumber",
				id: "serialnumber"
			}, {
				xtype: "checkboxfield",
				boxLabel: bundle.getMsg("nextgen.recipe.popup.saveRecipe.createAssemby"),
				name: "createAssembly",
				inputValue: "2",
				checked: false,
				id: "createAssembly"
			}]
		});
		return a
	}
});
Ext.define("SO.model.BomItemSubstituteModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "bomPkId",
		type: "int"
	}, {
		name: "bomItemPkId",
		type: "int"
	}, {
		name: "substitutePkId",
		type: "int"
	}, {
		name: "subComponentItemKey",
		type: "int"
	}, {
		name: "subComponentItemNumber"
	}, {
		name: "subComponentItemDesc"
	}, {
		name: "subQuantity",
		type: "int"
	}, {
		name: "active",
		type: "boolean"
	}, {
		name: "idx",
		type: "int"
	}],
	idProperty: "substitutePkId"
});
Ext.define("SO.model.BomItemModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "bomPkId",
		type: "int"
	}, {
		name: "bomItemPkId",
		type: "int"
	}, {
		name: "componentItemNumber"
	}, {
		name: "componentDescription"
	}, {
		name: "requiredQuantity",
		type: "float"
	}, {
		name: "quantity",
		type: "float"
	}, {
		name: "wipSupplyType"
	}, {
		name: "sequence",
		type: "int"
	}, {
		name: "partRev"
	}, {
		name: "subAssem",
		type: "int"
	}, {
		name: "opSeq",
		type: "int"
	}, {
		name: "department"
	}, {
		name: "partKey",
		type: "int"
	}, {
		name: "customerPartNumber"
	}, {
		name: "traceabilityCode",
		type: "auto"
	}, {
		name: "itemTypeKey",
		type: "int"
	}, {
		name: "itemType"
	}, {
		name: "idx",
		type: "int"
	}, {
		name: "assemblyItem"
	}, {
		name: "topAssemblyItem"
	}, {
		name: "nodesBomItem",
		type: "auto"
	}, {
		name: "lineNumber",
		type: "int"
	}, {
		name: "kvControlled",
		type: "boolean",
		defaultValue: true
	}, {
		name: "isSerialized",
		type: "boolean",
		defaultValue: false
	}, {
		name: "isSerializedOriginalValue",
		type: "boolean"
	}],
	idProperty: "bomItemPkId",
	hasMany: [{
		model: "SO.model.BomItemSubstituteModel",
		name: "nodes"
	}]
});
Ext.define("SO.model.BomModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "shopOrderKey"
	}, {
		name: "shopOrderNumber"
	}, {
		name: "partKey"
	}, {
		name: "partNumber"
	}, {
		name: "bomPkId"
	}, {
		name: "bomNo"
	}, {
		name: "myraw"
	}],
	idProperty: "shopOrderKey",
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	},
	hasMany: [{
		model: "SO.model.BomItemModel",
		name: "nodes"
	}]
});
Ext.define("SO.store.BomTreeStore", {
	extend: Ext.data.TreeStore,
	model: "SO.model.BomModel",
	root: {
		expanded: false
	},
	autoLoad: false,
	listeners: {
		beforeload: function(a, b) {
			return false
		},
		append: function(d, a, b, c) {
			a.set(a.data.myraw);
			if (!a.isRoot()) {
				this.getRootNode().set("expanded", true)
			}
			if (typeof(a.get("substitutePkId")) != "undefined") {
				a.set("text", a.get("subComponentItemNumber"));
				a.set("leaf", true);
				a.set("expanded", true);
				a.set("icon", window.windowSOContext.contextPath + "/resources/images/16X16/swap.png")
			} else {
				if (typeof(a.get("serialNumber")) != "undefined") {
					a.set("text", a.get("serialNumber"));
					a.set("leaf", true);
					a.set("expanded", true);
					a.set("icon", window.windowSOContext.contextPath + "/resources/images/16X16/assignment.png")
				} else {
					if (typeof(a.get("bomItemPkId")) != "undefined") {
						a.set("text", a.get("componentItemNumber"));
						a.set("icon", window.windowSOContext.contextPath + "/resources/images/16X16/component.png")
					} else {
						if (typeof(a.get("treeItem")) != "undefined") {} else {
							if (typeof(a.get("bomPkId")) != "undefined") {
								a.set("text", a.get("bomNo"));
								a.set("icon", window.windowSOContext.contextPath + "/resources/images/16X16/recipeDisplay.png")
							}
						}
					}
					a.set("leaf", (a.data.nodes == null || a.data.nodes.length <= 0) && (a.data.nodesBomItem == null || a.data.nodesBomItem.length <= 0));
					if (!a.get("leaf")) {
						if (a.data.nodes.length > 0) {
							a.appendChild(a.data.nodes)
						}
						if (a.data.nodesBomItem != undefined && a.data.nodesBomItem.length > 0) {
							a.appendChild(a.data.nodesBomItem)
						}
						a.set("expanded", true)
					}
				}
			}
		}
	}
});
Ext.define("SO.view.RecipeDisplay.RecipeDisplay", {
	extend: Ext.form.Panel,
	alias: "widget.recipedisplay",
	id: "recipedisplay",
	autoScroll: true,
	loadMask: true,
	autoWidth: true,
	autoHeight: true,
	scope: this,
	viewOnly: false,
	layout: {
		type: "vbox",
		align: "stretch"
	},
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("socontrol.browser.view.recipeDisplay");
		a.items = a.buildItems();
		a.dockedItems = a.buildDockedItems();
		a.on({
			afterrender: function() {
				checkPermissionsByContainer(a)
			}
		});
		this.callParent(arguments)
	},
	buildDockedItems: function() {
		var b = this;
		var a = {
			xtype: "toolbar",
			dock: "bottom",
			items: ["->",
			{
				action: "saverecipe",
				text: bundle.getMsg("socontrol.save"),
				hidden: b.viewOnly
			}, {
				action: "shoporderbrowser",
				text: bundle.getMsg("socontrol.cancel")
			}]
		};
		return a
	},
	buildItems: function() {
		var c = this.getTreePanel();
		var b = this.getSerialTreePanel();
		var d = Ext.create("Ext.tab.Panel", {
			id: "bomtabpanel",
			padding: "3 3 3 3",
			items: [c, b],
			flex: 0.3
		});
		var a = [{
			xtype: "panel",
			title: bundle.getMsg("socontrol.browser.view.shopOrderInfo"),
			collapsible: true,
			margin: "5 5 5 5",
			padding: "3 3 3 3",
			items: this.getInformationPanel()
		}, {
			xtype: "panel",
			id: "tabpanel",
			title: bundle.getMsg("socontrol.browser.view.bomInfo"),
			collapsible: false,
			margin: "5 5 5 5",
			padding: "3 3 3 3",
			flex: 1,
			layout: {
				type: "vbox",
				align: "stretch"
			},
			items: [{
				xtype: "panel",
				layout: {
					type: "hbox",
					align: "stretch"
				},
				flex: 1,
				items: [d,
				{
					xtype: "panel",
					padding: "27 3 3 0",
					height: "100%",
					id: "recipepanelholder",
					flex: 0.7
				}]
			}]
		}];
		return a
	},
	getInformationPanel: function() {
		var a;
		a = Ext.create("Ext.form.Panel", {
			border: 0,
			id: "recipesoinfopanel",
			autoWidth: true,
			autoHeight: true,
			layout: {
				type: "table",
				columns: 3
			},
			defaults: {
				labelClsExtra: "labelFieldDisplayCss"
			},
			items: [{
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.release.soNumber"),
				name: "shopOrderNumber",
				labelWidth: 150,
				labelAlign: "right"
			}, {
				xtype: "tbspacer",
				width: 230
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.release.traveler.partNumber"),
				name: "partNumber",
				labelWidth: 150,
				labelAlign: "right"
			}]
		});
		return a
	},
	getTreePanel: function() {
		var b = this;
		var a = Ext.create("Ext.tree.Panel", {
			id: "shopordertree",
			title: "Shop Order",
			store: Ext.create("SO.store.BomTreeStore"),
			rootVisible: false,
			tbar: [{
				xtype: "button",
				text: bundle.getMsg("socontrol.add"),
				action: "addbomitem",
				actionKey: "shopOrder.shopOrderBrowser.bomInformation.addComp",
				hidden: b.viewOnly
			}, {
				xtype: "button",
				text: bundle.getMsg("socontrol.remove"),
				action: "removebomitem",
				actionKey: "shopOrder.shopOrderBrowser.bomInformation.removeComp",
				disabled: true,
				hidden: b.viewOnly
			}]
		});
		return a
	},
	getSerialTreePanel: function() {
		var a = Ext.create("Ext.tree.Panel", {
			id: "serialtree",
			title: bundle.getMsg("socontrol.release.print.serialNumber"),
			height: "100%",
			store: Ext.create("SO.store.BomTreeStore"),
			rootVisible: false,
			flex: 1
		});
		return a
	}
});
Ext.define("SO.view.SerialNumberAssignment.SerialNumberAssignmentFilter", {
	extend: Ext.panel.Panel,
	alias: "widget.serialnumberassignmentfilter",
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("socontrol.assignmentTitle");
		a.store = Ext.getStore("SerialNumberAssignmentStore");
		a.border = 0;
		a.items = a.buildPanel();
		this.callParent(arguments)
	},
	listeners: {
		afterrender: function() {
			Ext.getCmp("soNumber").focus()
		}
	},
	buildPanel: function() {
		var a = [{
			xtype: "panel",
			layout: {
				type: "hbox",
				pack: "end"
			},
			border: 0,
			items: [{
				xtype: "panel",
				layout: "hbox",
				maxWidth: 1058,
				border: 0,
				style: {
					padding: "10px"
				},
				items: [{
					xtype: "customtextfield",
					fieldLabel: bundle.getMsg("socontrol.soNumber"),
					labelAlign: "top",
					name: "soNumberField",
					idProperty: "soNumberField",
					id: "soNumber",
					value: "",
					cls: "filterFieldsInline",
					labelClsExtra: "labelFilterCss",
					fieldCls: "inputFilterCss"
				}, {
					xtype: "customtextfield",
					fieldLabel: bundle.getMsg("socontrol.partNumber"),
					labelAlign: "top",
					name: "pNumberField",
					idProperty: "pNumberField",
					value: "",
					cls: "filterFieldsInline",
					labelClsExtra: "labelFilterCss",
					fieldCls: "inputFilterCss"
				}]
			}, {
				xtype: "panel",
				layout: {
					type: "vbox",
					align: "right",
					pack: "start"
				},
				style: {
					marginTop: "12px",
					marginRight: "10px",
					marginBottom: "5px"
				},
				width: 56,
				border: 0,
				items: [{
					xtype: "hiddenfield",
					name: "soFilteredHidden",
					id: "soFilteredHidden",
					idProperty: "soFilteredHidden",
					value: ""
				}, {
					xtype: "button",
					id: "filter",
					text: bundle.getMsg("socontrol.filter"),
					action: "assignmentFilter",
					iconCls: "filterButtonIcon"
				}, {
					xtype: "tbspacer",
					height: 5
				}, {
					xtype: "button",
					id: "clear",
					text: bundle.getMsg("socontrol.clear"),
					action: "assignmentClear",
					iconCls: "clearButtonIcon"
				}]
			}]
		}];
		return a
	}
});
Ext.define("SO.view.SerialNumberAssignment.SerialNumberAssignmentList", {
	extend: Ext.grid.Panel,
	alias: "widget.serialnumberassignmentlist",
	id: "serialnumberassignmentlist",
	autoWidth: true,
	autoHeight: true,
	initComponent: function() {
		var a = this;
		a.border = 0;
		a.dockedItems = a.buildFilterTopBar();
		a.stripeRows = false;
		a.store = Ext.getStore("SerialNumberAssignmentStore");
		a.columns = a.buildColumns();
		a.tbar = a.buildDockedItemsBar();
		a.bbar = a.buildBottomBar();
		a.selModel = Ext.create("Ext.selection.CheckboxModel", {
			mode: "SINGLE",
			showHeaderCheckbox: false,
			listeners: {
				selectionchange: function(h, f) {
					var g = Ext.getCmp("addToolbar");
					var c = Ext.getCmp("removeToolbar");
					var e = Ext.getCmp("printToolbar");
					var d = f[0];
					g.setDisabled(true);
					c.setDisabled(true);
					e.setDisabled(d == null);
					if (d != null) {
						if (!d.get("statusChecked")) {
							var b = Ext.getCmp("serialnumberassignmentlist");
							b.getEl().mask("Loading ..");
							Ext.Ajax.request({
								scope: this,
								url: window.windowSOContext.ajaxURL,
								params: {
									resourceID: "ShopOrderController.checkShopOrderStatusToAssign",
									id: d.getId()
								},
								success: function(j) {
									b.getEl().unmask();
									var i = Ext.decode(j.responseText);
									d.set("remainingQuantity", i.remainingQuantity);
									d.set("removableQuantity", i.removableQuantity);
									d.set("hasNonSerBatch", i.hasNonSerBatch);
									d.set("statusChecked", true);
									g.setDisabled(d.get("hasNonSerBatch") || !d.get("remainingQuantity") || d.get("remainingQuantity") < 1);
									c.setDisabled(!d.get("removableQuantity") || d.get("removableQuantity") < 1)
								},
								failure: function(i) {
									b.getEl().unmask();
									failureHandler(i, b.id)
								}
							})
						} else {
							g.setDisabled(d.get("hasNonSerBatch") || !d.get("remainingQuantity") || d.get("remainingQuantity") < 1);
							c.setDisabled(!d.get("removableQuantity") || d.get("removableQuantity") < 1)
						}
					}
				}
			}
		});
		a.on({
			afterrender: function() {
				checkPermissionsByContainer(a)
			}
		});
		a.callParent(arguments)
	},
	buildDockedItemsBar: function() {
		var a;
		a = Ext.create("Ext.toolbar.Toolbar", {
			items: [{
				icon: path + "resources/images/16X16/add.png",
				text: bundle.getMsg("socontrol.assign"),
				tooltip: bundle.getMsg("socontrol.assignSerialNumber"),
				id: "addToolbar",
				action: "onOpenAddPanelFromList",
				actionKey: "shopOrder.serialNumberAssignment.assignSerialNumber",
				scope: this,
				disabled: true
			}, {
				icon: path + "resources/images/16X16/remove.png",
				text: bundle.getMsg("socontrol.remove"),
				tooltip: bundle.getMsg("socontrol.removeSerialNumber"),
				id: "removeToolbar",
				action: "onOpenRemovePanelFromList",
				actionKey: "shopOrder.serialNumberAssignment.removeSerialNumber",
				scope: this,
				disabled: true
			}, {
				icon: path + "resources/images/16X16/print.png",
				text: bundle.getMsg("socontrol.print"),
				tooltip: bundle.getMsg("socontrol.printExportAssignedSerialNumber"),
				id: "printToolbar",
				action: "printExportAssignmentList",
				actionKey: "shopOrder.serialNumberAssignment.printAssignedSerialNumber",
				scope: this,
				disabled: true
			}, "->",
			{
				icon: path + "resources/images/16X16/print.png",
				tooltip: bundle.getMsg("socontrol.printExportFiltered"),
				scope: this,
				action: "printFiltered",
				actionKey: "shopOrder.serialNumberAssignment.printFilteredSerialNumber",
				id: "assignmentPrintTop"
			}]
		});
		return a
	},
	buildColumns: function() {
		var a = [];
		a = [{
			header: bundle.getMsg("socontrol.soNumber"),
			width: 120,
			flex: 1,
			sortable: true,
			dataIndex: "shopOrderNumber"
		}, {
			header: bundle.getMsg("socontrol.partNumber"),
			flex: 1,
			sortable: true,
			width: 140,
			dataIndex: "partNumberDataIndex"
		}, {
			header: bundle.getMsg("socontrol.status"),
			flex: 1,
			sortable: true,
			dataIndex: "shopOrderStatus"
		}, {
			header: bundle.getMsg("socontrol.quantityTable"),
			width: 60,
			sortable: true,
			dataIndex: "quantity"
		}, {
			header: bundle.getMsg("socontrol.boardsPerPanelList"),
			width: 60,
			sortable: true,
			dataIndex: "boardsPerPanel"
		}, {
			header: bundle.getMsg("socontrol.revisionTable"),
			width: 60,
			sortable: true,
			dataIndex: "revision"
		}, {
			header: bundle.getMsg("socontrol.startDate"),
			width: 110,
			sortable: true,
			dataIndex: "startDate"
		}, {
			header: bundle.getMsg("socontrol.completionDate"),
			flex: 1,
			dataIndex: "dueDate",
			sortable: true
		}];
		return a
	},
	buildFilterTopBar: function() {
		var a;
		a = Ext.create("SO.view.SerialNumberMaintenance.SerialNumberMaintenanceFilter", {
			assignScreen: true
		});
		a.title = bundle.getMsg("socontrol.assignmentTitle");
		return a
	},
	buildBottomBar: function() {
		var a;
		a = Ext.create("Ext.Custom.CustomPaging", {
			border: 0,
			store: Ext.getStore("SerialNumberAssignmentStore"),
			displayInfo: false,
			beforePageText: bundle.getMsg("socontrol.page"),
			afterPageText: ""
		});
		a.add("->");
		a.add({
			icon: path + "resources/images/16X16/print.png",
			tooltip: bundle.getMsg("socontrol.printExportFiltered"),
			scope: this,
			action: "printFiltered",
			actionKey: "shopOrder.serialNumberAssignment.printFilteredSerialNumber",
			id: "assignmentPrintBottom"
		});
		a.doLayout();
		return a
	}
});
Ext.define("SO.view.ShopOrderBrowser.ShopOrderBrowserFilter", {
	extend: Ext.panel.Panel,
	alias: "widget.shoporderbrowserfilter",
	height: "100%",
	width: "100%",
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("socontrol.browserTitle");
		a.store = Ext.getStore("ShopOrderBrowserStore");
		a.items = a.buildPanel();
		this.callParent(arguments)
	},
	listeners: {
		afterrender: function() {
			Ext.getCmp("soNumberField").focus()
		}
	},
	buildPanel: function() {
		var a = [{
			xtype: "container",
			layout: {
				type: "vbox",
				align: "stretch"
			},
			width: "100%",
			border: 0,
			items: [{
				xtype: "panel",
				layout: {
					type: "column"
				},
				border: 0,
				style: {
					padding: "10px",
					marginRight: "0px"
				},
				items: [{
					xtype: "panel",
					border: 0,
					baseCls: "float_right_panel",
					items: [{
						xtype: "hiddenfield",
						name: "soFilteredHidden",
						id: "soFilteredHidden",
						width: 130,
						idProperty: "soFilteredHidden",
						value: ""
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.soNumber"),
						labelAlign: "top",
						name: "soNumberField",
						idProperty: "soNumberField",
						width: 130,
						id: "soNumberField",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.partNumber"),
						labelAlign: "top",
						name: "pNumberField",
						width: 130,
						idProperty: "pNumberField",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.revisionTable"),
						labelAlign: "top",
						name: "revField",
						width: 130,
						idProperty: "revField",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "combobox",
						fieldLabel: bundle.getMsg("socontrol.soType"),
						labelAlign: "top",
						name: "soTypeField",
						idProperty: "soTypeField",
						valueField: "id",
						displayField: "soTypeDescription",
						value: 3,
						width: 130,
						cls: "comboFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "comboFilterCss",
						editable: false,
						store: new Ext.data.ArrayStore({
							fields: ["id", "soTypeDescription"],
							listeners: {
								load: function(b) {
									b.sort("soTypeDescription", "ASC")
								}
							},
							data: [
								[1, bundle.getMsg("socontrol.soOracle")],
								[2, bundle.getMsg("socontrol.soStandard")],
								[3, bundle.getMsg("socontrol.all")]
							]
						})
					}, {
						xtype: "combobox",
						fieldLabel: bundle.getMsg("socontrol.status"),
						labelAlign: "top",
						name: "soStatusListField",
						idProperty: "soStatusListField",
						multiSelect: true,
						valueField: "id",
						displayField: "soStatusDescription",
						value: 6,
						width: 130,
						cls: "comboFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "comboFilterCss",
						editable: false,
						store: new Ext.data.ArrayStore({
							fields: ["id", "soStatusDescription"],
							listeners: {
								load: function(b) {
									b.sort("soStatusDescription", "ASC")
								}
							},
							data: [
								[1, bundle.getMsg("socontrol.soOnHold")],
								[2, bundle.getMsg("socontrol.soShowReleased")],
								[3, bundle.getMsg("socontrol.soShowOpened")],
								[4, bundle.getMsg("socontrol.soShowClosed")],
								[5, bundle.getMsg("socontrol.soShowCancelled")],
								[6, bundle.getMsg("socontrol.all")]
							]
						})
					}, {
						xtype: "panel",
						layout: {
							type: "vbox"
						},
						id: "painelButtons",
						baseCls: "float_right_panel",
						style: {
							marginLeft: "15px"
						},
						border: 0,
						items: [{
							xtype: "button",
							id: "filter",
							text: bundle.getMsg("socontrol.filter"),
							action: "browserFilter",
							iconCls: "filterButtonIcon"
						}, {
							xtype: "tbspacer",
							height: 5
						}, {
							xtype: "button",
							id: "clear",
							text: bundle.getMsg("socontrol.clear"),
							action: "browserClear",
							iconCls: "clearButtonIcon"
						}]
					}]
				}]
			}]
		}];
		return a
	}
});
Ext.define("SO.view.ShopOrderBrowser.ShopOrderBrowserList", {
	extend: Ext.grid.Panel,
	alias: "widget.shoporderbrowserlist",
	id: "shoporderbrowserlist",
	autoWidth: true,
	autoHeight: true,
	initComponent: function() {
		var a = this;
		a.border = 0;
		a.dockedItems = a.buildFilterTopBar();
		a.stripeRows = false;
		a.store = Ext.getStore("ShopOrderBrowserStore");
		a.columns = a.buildColumns();
		a.tbar = a.buildDockedItemsBar();
		a.bbar = a.buildPagingBottomBar();
		a.viewConfig = a.buildViewConfig();
		a.selModel = Ext.create("Ext.selection.CheckboxModel", {
			mode: "SINGLE",
			showHeaderCheckbox: false,
			listeners: {
				selectionchange: function(e, b) {
					var c = Ext.getCmp("bomToolbar");
					var d = Ext.getCmp("infoToolbar");
					c.setDisabled(true);
					d.setDisabled(true);
					if (b[0]) {
						d.setDisabled(false);
						if (b[0].data.bompkID > 0) {
							c.setDisabled(false)
						}
					}
				}
			}
		});
		a.on({
			afterrender: function() {
				checkPermissionsByContainer(a)
			}
		});
		a.callParent(arguments)
	},
	buildViewConfig: function() {
		var a = {
			getRowClass: function(b, e, d, c) {
				if (b.get("serialNumberStatus") == 2) {
					return "rowSoGreen"
				} else {
					if (b.get("serialNumberStatus") == 3) {
						return "rowSoRed"
					} else {
						return "rowSoBlack"
					}
				}
			}
		};
		return a
	},
	buildDockedItemsBar: function() {
		var a;
		a = Ext.create("Ext.toolbar.Toolbar", {
			items: [{
				icon: path + "resources/images/16X16/info.png",
				text: bundle.getMsg("socontrol.browser.view.shopOrderInfo"),
				id: "infoToolbar",
				scope: this,
				disabled: true,
				handler: this.openInfoWindow
			}, {
				icon: path + "resources/images/16X16/bom.png",
				text: bundle.getMsg("socontrol.browser.view.bomInfo"),
				id: "bomToolbar",
				scope: this,
				disabled: true,
				handler: this.openBomWindow
			}, "->",
			{
				text: bundle.getMsg("socontrol.printTraveler"),
				iconCls: "print",
				scope: this,
				action: "printtravelerlist",
				id: "printtravelerlistmenubtn"
			}, {
				text: bundle.getMsg("socontrol.rePrintTraveler"),
				iconCls: "print",
				scope: this,
				action: "reprinttravelerlist",
				id: "reprinttravelerlistmenubtn"
			}, {
				icon: path + "resources/images/16X16/print.png",
				tooltip: bundle.getMsg("socontrol.printExportFiltered"),
				scope: this,
				action: "printFiltered",
				actionKey: "shopOrder.shopOrderBrowser.printExportFilteredShopOrderBrowser",
				id: "browserPrintTop"
			}]
		});
		return a
	},
	openInfoWindow: function() {
		var b = Ext.getCmp("shoporderbrowserlist");
		var c = b.getSelectionModel().getSelection();
		var a = c[0];
		if (a) {
			b.fireEvent("iconclick", "info", this.id, a, {
				viewOnly: !checkPermission("shopOrder.shopOrderBrowser.shopOrderInformation")
			})
		}
	},
	openBomWindow: function() {
		var b = Ext.getCmp("shoporderbrowserlist");
		var c = b.getSelectionModel().getSelection();
		var a = c[0];
		if (a) {
			b.fireEvent("iconclick", "bom", this.id, a, {
				viewOnly: !checkPermission("shopOrder.shopOrderBrowser.bomInformation")
			})
		}
	},
	buildColumns: function() {
		var a = [];
		a = [{
			header: bundle.getMsg("socontrol.soNumber"),
			width: 140,
			dataIndex: "shopOrderNumber",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.partNumber"),
			flex: 1,
			dataIndex: "partNumberDataIndex",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.release.oracleSO"),
			flex: 1,
			dataIndex: "oracleShopOrder",
			sortable: true,
			renderer: function(f, c, b, h, e, d, g) {
				if (f == true) {
					return '<input type="checkbox" disabled checked />'
				} else {
					return '<input type="checkbox" disabled />'
				}
			}
		}, {
			header: bundle.getMsg("socontrol.status"),
			flex: 1,
			dataIndex: "shopOrderStatus",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.quantityTable"),
			flex: 1,
			dataIndex: "quantity",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.boardsPerPanelList"),
			flex: 1,
			dataIndex: "boardsPerPanel",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.revisionTable"),
			flex: 1,
			dataIndex: "revision",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.startDate"),
			flex: 1,
			dataIndex: "startDate",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.completionDate"),
			flex: 1,
			dataIndex: "dueDate",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.statusChangeDateAcronym"),
			flex: 1,
			dataIndex: "statusChangeDate",
			sortable: true
		}, {
			header: bundle.getMsg("socontrol.statusChangeTimeAcronym"),
			flex: 1,
			dataIndex: "statusChangeTime",
			sortable: true
		}];
		return a
	},
	buildFilterTopBar: function() {
		var a;
		a = Ext.create("SO.view.ShopOrderBrowser.ShopOrderBrowserFilter", {});
		return a
	},
	buildPagingBottomBar: function() {
		var a;
		a = Ext.create("Ext.Custom.CustomPaging", {
			store: Ext.getStore("ShopOrderBrowserStore"),
			displayInfo: false,
			beforePageText: bundle.getMsg("socontrol.page"),
			afterPageText: ""
		});
		a.add("->");
		a.add({
			icon: path + "resources/images/16X16/print.png",
			tooltip: bundle.getMsg("socontrol.printExportFiltered"),
			scope: this,
			action: "printFiltered",
			actionKey: "shopOrder.shopOrderBrowser.printExportFilteredShopOrderBrowser",
			id: "browserPrintBottom"
		});
		a.doLayout();
		return a
	}
});
Ext.define("SO.view.ShopOrderBrowser.RecipePanels", {
	statics: {
		getRootPanel: function() {
			var a = Ext.create("Ext.form.Panel", {
				border: 0,
				title: "Deviation Information",
				id: "sobomdeviationinfoform",
				autoWidth: true,
				defaults: {
					labelClsExtra: "labelFieldDisplayCss"
				},
				items: [{
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.browser.deviationReference"),
					name: "deviationReference",
					labelWidth: 150,
					labelAlign: "right"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.user"),
					name: "userLogin",
					labelWidth: 150,
					labelAlign: "right"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.date"),
					name: "dateTime",
					labelWidth: 150,
					labelAlign: "right"
				}]
			});
			return a
		},
		getSubstitutePanel: function() {
			var a = Ext.create("Ext.form.Panel", {
				id: "parentsubstform",
				border: 25,
				flex: 1,
				anchor: "100% 100%",
				minWidth: 250,
				title: bundle.getMsg("nextgen.recipe.oldPart"),
				autoWidth: true,
				layout: {
					type: "vbox",
					align: "stretch"
				},
				defaults: {
					labelClsExtra: "labelFieldDisplayCss"
				},
				items: [{
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.partNumber"),
					name: "componentItemNumber",
					labelWidth: 150,
					labelAlign: "right"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.maintenance.partNumber.description"),
					name: "componentDescription",
					labelWidth: 150,
					labelAlign: "right"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.maintenance.partNumber.quantity"),
					name: "quantity",
					labelWidth: 150,
					labelAlign: "right"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.supplyType"),
					name: "wipSupplyType",
					labelWidth: 150,
					labelAlign: "right"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.seq"),
					name: "sequence",
					labelWidth: 150,
					labelAlign: "right"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.release.mapping.operationSequence"),
					name: "opSeq",
					labelWidth: 150,
					labelAlign: "right"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.subAssembly"),
					name: "subAssem",
					labelWidth: 150,
					labelAlign: "right"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.department"),
					name: "department",
					labelWidth: 150,
					labelAlign: "right"
				}]
			});
			var c = Ext.create("Ext.form.Panel", {
				id: "componentinformationform",
				border: 0,
				flex: 1,
				title: "Substitute Part",
				minWidth: 250,
				autoWidth: true,
				layout: {
					type: "table",
					columns: 1
				},
				defaults: {
					labelClsExtra: "labelFieldDisplayCss"
				},
				items: [{
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.partNumber"),
					name: "subComponentItemNumber",
					labelWidth: 150,
					labelAlign: "right"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.maintenance.partNumber.description"),
					name: "subComponentItemDesc",
					labelWidth: 150,
					labelAlign: "right"
				}, {
					xtype: "numberfield",
					id: "qtytextfield",
					fieldLabel: bundle.getMsg("socontrol.maintenance.partNumber.quantity"),
					name: "subQuantity",
					labelWidth: 150,
					labelAlign: "right",
					minValue: 0,
					maxValue: 999999999,
					allowBlank: false,
					allowDecimals: true,
					decimalPrecision: 6,
					listeners: {
						afterrender: function(d) {
							d.focus()
						}
					}
				}, {
					xtype: "checkbox",
					id: "checkboxactiveid",
					name: "active",
					labelWidth: 150,
					labelAlign: "right",
					inputValue: true,
					checked: false,
					fieldLabel: bundle.getMsg("socontrol.recipe.active"),
					style: {
						marginTop: -8
					}
				}]
			});
			var b = Ext.create("Ext.form.Panel", {
				border: 0,
				autoWidth: true,
				id: "formmain",
				height: "100%",
				flex: 1,
				layout: {
					type: "hbox",
					align: "stretch"
				},
				dockedItems: [{
					xtype: "toolbar",
					dock: "bottom",
					id: "toolbarComponentInf",
					padding: "0 0 0 0",
					margin: "0 0 0 0",
					items: ["->",
					{
						xtype: "button",
						text: bundle.getMsg("socontrol.cancel"),
						action: "cancelsubst"
					}]
				}],
				items: [a, c]
			});
			return b
		},
		buildDockedItemsBarFoRef: function() {
			var a = Ext.getCmp("bomtabpanel").getActiveTab().id == "serialtree";
			var b = Ext.create("Ext.toolbar.Toolbar", {
				items: [{
					action: "addRef",
					actionKey: "shopOrder.shopOrderBrowser.bomInformation.addRef",
					icon: path + "resources/images/16X16/add.png",
					text: bundle.getMsg("socontrol.add"),
					tooltip: bundle.getMsg("socontrol.add"),
					hidden: a
				}, {
					action: "deleteRef",
					actionKey: "shopOrder.shopOrderBrowser.bomInformation.deleteRef",
					icon: path + "resources/images/16X16/delete.png",
					text: bundle.getMsg("socontrol.delete"),
					tooltip: bundle.getMsg("socontrol.delete"),
					hidden: a
				}]
			});
			return b
		},
		getComponentPanel: function() {
			var a = Ext.getCmp("bomtabpanel").getActiveTab().id == "serialtree";
			var f = checkPermission("shopOrder.shopOrderBrowser.bomInformation.updateRef") && !a,
				c = Ext.create("SO.store.RefDesignatorStore"),
				d = Ext.create("Ext.grid.Panel", {
					flex: 0.2,
					width: "50%",
					padding: "0 0 0 0",
					margin: "0 0 0 0",
					tbar: this.buildDockedItemsBarFoRef(),
					autoScroll: true,
					listeners: {
						validateedit: function(g, i) {
							var h = g.editor.form.findField("refDesignator");
							h.setValue(h.getValue().toUpperCase().trim())
						}
					},
					store: c,
					plugins: f ? [Ext.create("Ext.grid.plugin.RowEditing", {
						pluginId: "rowEditing"
					})] : [],
					id: "componentinfogrid",
					columns: [{
						header: bundle.getMsg("socontrol.recipe.refDesignator"),
						flex: 1,
						dataIndex: "refDesignator",
						sortable: false,
						editor: {
							xtype: "textfield",
							allowBlank: false
						}
					}]
				});
			var b = Ext.create("Ext.form.Panel", {
				id: "componentinformationform",
				border: 0,
				flex: 0.8,
				width: "80px",
				padding: "10 10 10 10",
				margin: "0 0 0 0",
				layout: {
					type: "table",
					columns: 2,
					tableAttrs: {
						style: {
							width: "100%",
							tableLayout: "fixed"
						}
					},
					tdAttrs: {
						width: "50%"
					}
				},
				fieldDefaults: {
					labelWidth: 120,
					labelAlign: "right"
				},
				defaults: {
					labelClsExtra: "labelFieldDisplayCss"
				},
				items: [{
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.partNumber"),
					name: "componentItemNumber",
					padding: "0 0 0 3"
				}, {
					xtype: "numberfield",
					id: "qtytextfield",
					fieldLabel: bundle.getMsg("socontrol.maintenance.partNumber.quantity"),
					name: "quantity",
					minValue: 0,
					maxValue: 999999999,
					allowBlank: false,
					allowDecimals: true,
					listeners: {
						afterrender: function(g) {
							g.focus()
						}
					}
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.maintenance.partNumber.description"),
					name: "componentDescription",
					padding: "0 0 0 3",
					fieldCls: "overFlowDisplayField"
				}, {
					xtype: "numberfield",
					id: "requiredQuantitytextfield",
					fieldLabel: bundle.getMsg("socontrol.maintenance.partNumber.requiredquantity"),
					name: "requiredQuantity",
					minValue: 0,
					maxValue: 999999999,
					allowBlank: false,
					allowDecimals: true,
					listeners: {
						afterrender: function(g) {
							g.focus()
						}
					}
				}, {
					xtype: "combobox",
					fieldLabel: bundle.getMsg("socontrol.supplyType"),
					displayField: "wipSupplyType",
					valueField: "wipSupplyType",
					name: "wipSupplyType",
					editable: false,
					store: new Ext.data.ArrayStore({
						fields: ["wipSupplyType"],
						data: [
							["PUSH"],
							["PULL"]
						]
					})
				}, {
					xtype: "customtextfield",
					fieldLabel: bundle.getMsg("socontrol.department"),
					name: "department",
					maxLength: 20,
					padding: "0 0 0 3"
				}, {
					xtype: "customtextfield",
					fieldLabel: bundle.getMsg("socontrol.recipe.step"),
					name: "sequence",
					regex: /^\d+$/,
					maskRe: /[0-9.]/
				}, {
					xtype: "customtextfield",
					fieldLabel: bundle.getMsg("socontrol.release.report.revision"),
					name: "partRev",
					maxLength: 8,
					padding: "0 0 0 3"
				}, {
					xtype: "customtextfield",
					fieldLabel: bundle.getMsg("socontrol.release.mapping.operationSequence"),
					name: "opSeq",
					regex: /^\d+$/,
					maskRe: /[0-9.]/
				}, {
					xtype: "customtextfield",
					fieldLabel: bundle.getMsg("salesOrder.line.customerPartNumb"),
					name: "customerPartNumber",
					padding: "0 0 0 3"
				}, {
					xtype: "customtextfield",
					fieldLabel: bundle.getMsg("socontrol.recipe.traceabilityCode"),
					keep_enabled: !a,
					name: "traceabilityCode"
				}, {
					xtype: "combobox",
					fieldLabel: bundle.getMsg("socontrol.recipe.itemType"),
					name: "itemTypeKey",
					id: "itemTypeCombo",
					valueField: "itemTypeKey",
					displayField: "itemType",
					editable: true,
					forceSelection: true,
					allowBlank: true,
					queryMode: "local",
					labelClsExtra: "labelFieldDisplayCss",
					store: Ext.create("Ext.data.Store", {
						fields: ["itemTypeKey", "itemType"],
						autoLoad: false,
						proxy: {
							async: true,
							type: "ajax",
							format: "json",
							method: "GET",
							url: window.windowSOContext.ajaxURL,
							extraParams: {
								resourceID: "BomController.findBomItemType"
							},
							reader: {
								root: "data",
								totalProperty: "totalCount"
							}
						}
					}),
					listConfig: {
						loadMask: true
					},
					padding: "0 0 0 3"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.recipe.topAssembly"),
					name: "topAssemblyItem",
					id: "topAssemblyItem",
					emptyText: "",
					padding: "0 0 0 3"
				}, {
					xtype: "customtextfield",
					fieldLabel: bundle.getMsg("socontrol.recipe.lineNumber"),
					name: "lineNumber"
				}, {
					xtype: "displayfield",
					fieldLabel: bundle.getMsg("socontrol.recipe.assembly"),
					name: "assemblyItem",
					id: "assemblyItem",
					emptyText: "",
					padding: "0 0 0 3"
				}, {
					xtype: "checkbox",
					id: "checkboxKVControll",
					name: "kvControlled",
					fieldLabel: bundle.getMsg("socontrol.recipe.kvControlled"),
					keep_enabled: true
				}, {
					xtype: "checkbox",
					id: "checkboxserialized",
					name: "isSerialized",
					inputValue: true,
					checked: false,
					fieldLabel: bundle.getMsg("socontrol.recipe.isSerialized"),
					keep_enabled: true
				}, {
					xtype: "checkbox",
					name: "isSerializedOriginalValue",
					hidden: true
				}]
			});
			var e = Ext.create("Ext.form.Panel", {
				border: 0,
				autoWidth: true,
				id: "formmain",
				layout: {
					type: "hbox",
					align: "stretch"
				},
				title: bundle.getMsg("socontrol.recipe.componentInformation"),
				dockedItems: [{
					xtype: "toolbar",
					dock: "bottom",
					id: "toolbarComponentInf",
					padding: "0 0 0 0",
					margin: "0 0 0 0",
					items: ["->",
					{
						xtype: "button",
						text: bundle.getMsg("socontrol.cancel"),
						action: "cancelcompinfo",
						hidden: a
					}, {
						xtype: "button",
						text: bundle.getMsg("socontrol.recipe.substitute"),
						action: "compsubstitute",
						hidden: a,
						actionKey: "shopOrder.shopOrderBrowser.bomInformation.substitutePartNumber"
					}]
				}],
				items: [b, d]
			});
			return e
		}
	}
});
Ext.define("PnRecipeEditor", {
	extend: Ext.form.ComboBox,
	name: "pnrecipeeditor",
	alias: "widget.pnrecipeeditor",
	displayField: "partNumber",
	valueField: "partNumber",
	minChars: 3,
	pageSize: 25,
	forceSelection: true,
	queryDelay: 500,
	typeAhead: false,
	hideTrigger: true,
	anchor: "100%",
	submitEmptyText: false,
	listeners: {
		blur: function(a) {
			if (a.getStore().loading == true) {
				a.clearValue();
				a.value = "";
				a.inputEl.dom.value = ""
			}
		}
	},
	initComponent: function() {
		this.store = Ext.create("Ext.data.Store", {
			model: "Common.model.PartNumberModel",
			pageSize: 25,
			remoteSort: false,
			autoLoad: false,
			proxy: {
				type: "ajax",
				format: "json",
				url: window.windowSOContext.ajaxURL,
				appendId: false,
				extraParams: {
					resourceID: "GenericFetchController.getPartNumbers"
				},
				reader: {
					root: "data",
					totalProperty: "totalCount"
				}
			}
		});
		this.listConfig = {
			loadingText: bundle.getMsg("socontrol.msgSearch"),
			emptyText: bundle.getMsg("socontrol.msgNoMatchingPart")
		};
		this.callParent(arguments)
	}
});
Ext.define("SO.view.ShopOrderMenu", {
	extend: Ext.window.Window,
	alias: "widget.shopordermenu",
	renderTo: "xmain",
	id: "shopordermenu",
	header: false,
	height: "100%",
	width: "100%",
	layout: "fit",
	resizable: false,
	collapsible: false,
	maximized: true,
	closable: true,
	closeAction: "hide",
	margin: 0,
	padding: 0,
	border: 0,
	bodyStyle: "background: rgba(255, 255, 255, 0.9);",
	style: {
		"background-color": "transparent"
	},
	titleCollapse: false,
	userClosable: false,
	onHide: function() {
		var a = this;
		a.el.fadeOut({
			endOpacity: 0,
			easing: "easeOut",
			duration: 300,
			remove: false,
			opacity: 0,
			callback: function() {
				a.el.hide()
			}
		})
	},
	beforeShow: function() {
		var a = this;
		a.el.fadeIn({
			endOpacity: 1,
			easing: "easeOut",
			duration: 300,
			remove: false,
			opacity: 1
		})
	},
	listeners: {
		beforehide: function(a) {
			if (!a.userClosable) {
				return false
			}
		},
		show: function(a) {
			a.focus()
		},
		click: {
			element: "el",
			fn: function() {
				Ext.getCmp("shopordermenu").hide()
			}
		}
	},
	initComponent: function() {
		var a = this;
		Ext.Ajax.request({
			async: false,
			url: window.windowSOContext.ajaxURL,
			method: "GET",
			params: {
				resourceID: "PermissionCommonsController.userPermissions"
			},
			success: function(b) {
				var d = Ext.decode(b.responseText);
				if (d.data) {
					permissions = d.data
				}
				var c = new Array();
				if (checkPermission("shopOrder.shopOrderRelease")) {
					c.push(a.buildMenuRelease())
				}
				if (checkPermission("shopOrder.shopOrderBrowser")) {
					c.push(a.buildMenuBrowser())
				}
				if (checkPermission("shopOrder.serialNumberMaintenance")) {
					c.push(a.buildMenuMaintenance())
				}
				if (checkPermission("shopOrder.serialNumberAssignment")) {
					c.push(a.buildMenuAssignment())
				}
				if (checkPermission("shopOrder.salesOrderBrowser")) {
					c.push(a.buildMenuSalesOrder())
				}
				a.items = {
					xtype: "container",
					style: {
						"background-color": "transparent"
					},
					layout: {
						type: "vbox",
						align: "stretch"
					},
					padding: 0,
					border: 0,
					margin: 0,
					items: [{
						style: {
							"background-color": "transparent"
						},
						xtype: "container",
						padding: "15 0 0 0",
						layout: {
							type: "hbox",
							pack: "center"
						},
						items: c
					}]
				}
			}
		});
		Ext.Ajax.request({
			async: true,
			url: window.windowSOContext.ajaxURL,
			method: "GET",
			params: {
				resourceID: "ShopOrderController.getAllGenAttributeShopOrder"
			},
			success: function(b) {
				var c = Ext.decode(b.responseText);
				label_engine_context = c.label_engine_context;
				label_download_enable = c.label_download_enable;
				path_download_file = c.path_download_file;
				label_engine_token_jmds = c.label_engine_token_jmds
			},
			failure: function(b) {
				label_engine_context = "";
				label_download_enable = false;
				path_download_file = "";
				label_engine_token_jmds = ""
			}
		});
		a.callParent(arguments)
	},
	buildMenuRelease: function() {
		var a = Ext.create("SO.view.MainMenuButtonSO", {
			id: "shoporderrelease",
			action: "shoporderreleaselist",
			icon: path + "resources/images/72X72/release.png",
			text: bundle.getMsg("socontrol.releaseTitle")
		});
		return a
	},
	buildMenuBrowser: function() {
		var a = Ext.create("SO.view.MainMenuButtonSO", {
			id: "shoporderbrowser",
			action: "shoporderbrowserlist",
			icon: path + "resources/images/72X72/browser.png",
			text: bundle.getMsg("socontrol.browserTitle")
		});
		return a
	},
	buildMenuMaintenance: function() {
		var a = Ext.create("SO.view.MainMenuButtonSO", {
			id: "serialnumbermaintenancebutton",
			action: "serialnumbermaintenancelist",
			icon: path + "resources/images/72X72/maintenance.png",
			text: bundle.getMsg("socontrol.maintenanceTitle")
		});
		return a
	},
	buildMenuAssignment: function() {
		var a = Ext.create("SO.view.MainMenuButtonSO", {
			id: "assignmentbutton",
			action: "serialnumberassignmentlist",
			icon: path + "resources/images/72X72/assignment.png",
			text: bundle.getMsg("socontrol.assignmentTitle")
		});
		return a
	},
	buildMenuSalesOrder: function() {
		var a = Ext.create("SO.view.MainMenuButtonSO", {
			id: "salesorderbutton",
			action: "salesorderlist",
			icon: path + "resources/images/72X72/salesOrder.png",
			text: bundle.getMsg("socontrol.salesOrderTitle")
		});
		return a
	}
});
Ext.define("SO.view.MainMenuButtonSO", {
	extend: Ext.container.Container,
	name: "mainmenubuttonSO",
	alias: "widget.mainmenubuttonSO",
	layout: {
		type: "table",
		columns: 1
	},
	action: "defaultaction",
	width: 130,
	height: 130,
	margin: 5,
	padding: "10 0 0 0",
	cls: "mainmenubutton",
	style: {
		opacity: "1"
	},
	listeners: {
		click: {
			element: "el",
			fn: function() {
				Ext.getCmp("shopordermenu").userClosable = true;
				Ext.getCmp("shopordermenu").hide();
				Ext.create("Ext.tip.ToolTip", {
					target: "mainmenuheadercontSO",
					html: "Click or press ESC to collapse the Menu"
				});
				SO.controller.ShopOrderController.prototype.onMenuClicked(Ext.getCmp(this.id))
			}
		}
	},
	initComponent: function() {
		var a = this;
		a.items = [Ext.create("Ext.Img", {
			src: a.icon,
			padding: "0 0 10 0"
		}),
		{
			xtype: "label",
			text: a.text
		}];
		this.callParent(arguments)
	}
});
Ext.define("SO.view.SOMainWindow", {
	extend: Ext.window.Window,
	alias: "widget.somainwindow",
	id: "somainwindow",
	renderTo: "xmain",
	header: false,
	autoWidth: true,
	width: "100%",
	height: "100%",
	layout: "fit",
	header: false,
	resizable: false,
	maximized: true,
	padding: 0,
	closable: false,
	border: 0,
	titleCollapse: false,
	userClosable: false,
	listeners: {
		resize: function(b, e, d, c) {
			var a = Ext.getCmp("xmain");
			if (typeof a != "undefined") {
				a.resizePanel()
			}
		}
	},
	initComponent: function() {
		var a = this;
		a.callParent(arguments)
	}
});
Ext.define("SO.Custom.AddMultipleSerialNumberWindow", {
	extend: Ext.window.Window,
	alias: "widget.addmultipleserialwindow",
	id: "addmultipleserialwindow",
	autoWidth: true,
	autoHeight: true,
	resizable: false,
	buttonId: "",
	modal: true,
	constrain: true,
	renderTo: "xmain",
	layout: "fit",
	customTitle: null,
	quantity: "",
	assigned: "",
	initComponent: function() {
		var a = this;
		a.title = a.customTitle == null ? bundle.getMsg("socontrol.addSerialNumber") : a.customTitle, a.items = a.buildItems();
		a.dockedItems = a.buildDockedItems();
		a.callParent(arguments);
		a.border = 0
	},
	buildItems: function() {
		var b = Ext.create("Ext.grid.Panel", {
			id: "serialGrid",
			flex: 6.5,
			columns: [{
				header: bundle.getMsg("socontrol.serialNumber"),
				dataIndex: "serialNumber",
				flex: 1
			}, {
				header: bundle.getMsg("socontrol.status"),
				dataIndex: "unitStatusKey",
				width: 60
			}, {
				header: bundle.getMsg("socontrol.salesOrderSnAssignment.label.lineCapacity"),
				dataIndex: "quantity",
				width: 60
			}, {
				header: bundle.getMsg("socontrol.soNumber"),
				dataIndex: "shopOrderNumber",
				flex: 1
			}],
			stripeRows: true,
			enableDrag: true,
			enableDrop: false,
			stripeRows: true,
			store: Ext.getStore("SerialNumberStore"),
			style: {
				marginLeft: "5px",
				marginRight: "5px",
				marginBottom: "5px"
			},
			selModel: Ext.create("Ext.selection.RowModel", {
				mode: "MULTI"
			}),
			bbar: Ext.create("Ext.Custom.CustomPaging", {
				border: 0,
				store: Ext.getStore("SerialNumberStore"),
				displayInfo: false,
				beforePageText: bundle.getMsg("socontrol.page"),
				afterPageText: "",
				listeners: {
					afterrender: function() {
						viewport = Ext.getCmp("addmultipleserialwindow");
						if (viewport.buttonId == "onRemoveSerial") {
							this.down("#export").hide()
						}
					}
				}
			}),
			dockedItems: {
				xtype: "panel",
				layout: {
					type: "column",
					columns: 1
				},
				cls: "transparentBackground",
				baseCls: "transparentBackground",
				bodyCls: "transparentBackground",
				items: [{
					xtype: "customtriggerfield",
					fieldLabel: bundle.getMsg("Shop Order"),
					labelAlign: "top",
					labelWidth: 100,
					id: "soNumber" + this.buttonId,
					value: "",
					columnWidth: 1,
					enableKeyEvents: true,
					triggerCls: "findTriggerButton",
					onTrigger2Click: function(f) {
						var d = this;
						if (!d.hideTrigger) {
							d.fireEvent("trigger2click", d, f)
						}
					},
					listeners: {
						blur: function(d) {
							if (d.getValue()) {
								d.setValue(d.getValue().trim())
							}
						}
					}
				}]
			},
			viewConfig: {
				plugins: {
					ddGroup: "serialdd",
					ptype: "gridviewdragdrop",
					enableDrop: false
				},
				getRowClass: function(d, g) {
					var f = Ext.getCmp("serialList").getValue();
					var e = new RegExp("^" + d.data.serialNumber + "( )*$", "gim");
					if (f.match(e)) {
						return "rowBoldRed"
					}
					return "rowGray"
				}
			}
		});
		var a = new Ext.form.FormPanel({
			id: "formPanel",
			flex: 3.5,
			border: 0,
			layout: {
				type: "vbox",
				align: "stretch"
			},
			style: {
				marginLeft: "5px",
				marginRight: "5px",
				marginBottom: "5px"
			},
			items: [{
				xtype: "textareafield",
				name: "serialList",
				fieldLabel: bundle.getMsg("socontrol.enterMultipleSN"),
				labelAlign: "top",
				id: "serialList",
				flex: 1,
				value: "",
				autoScroll: true,
				enableKeyEvents: true,
				validator: this.validList,
				listeners: {
					change: function(k, j, f, g) {
						var e = Ext.getCmp("addmultipleserialwindow"),
							d = Ext.getCmp("serialList").getValue().trim(),
							h = 0,
							i = 0;
						if (d != "") {
							h = Ext.getCmp("serialList").getValue().trim().split("\n").length
						}
						if (e.buttonId == "onAddSerial") {
							i = parseInt(e.assigned) + h
						} else {
							i = parseInt(e.assigned) - h
						}
						Ext.getCmp("totalAssignedField").setValue(i + "/" + e.quantity);
						Ext.getCmp("serialGrid").getView().refresh(true);
						Ext.getCmp("totalSerials").setValue(i)
					},
					blur: function(d) {
						d.setValue(d.getValue().trim())
					}
				}
			}, {
				xtype: "hiddenfield",
				name: "totalSerials",
				id: "totalSerials",
				value: 0
			}],
			listeners: {
				afterrender: function(d, e) {
					var g = d.body.dom;
					var f = Ext.getCmp("serialList");
					Ext.create("Ext.dd.DropTarget", g, {
						ddGroup: "serialdd",
						notifyEnter: function(j, i, h) {
							d.body.stopAnimation();
							d.body.highlight()
						},
						notifyDrop: function(k, j, i) {
							var h = k.dragData.records;
							h.forEach(function(l) {
								so_application.getController("SalesOrderController").addSerialFromGrid(f, l.data.serialNumber)
							});
							return true
						}
					})
				}
			}
		});
		var c = Ext.getCmp("somainwindow");
		items = {
			xtype: "container",
			id: "addserialwindowform",
			bodyPadding: "5",
			width: 0.7 * c.getWidth(),
			height: 0.7 * c.getHeight(),
			style: {
				margin: "5px"
			},
			layout: {
				type: "hbox",
				align: "stretch"
			},
			items: [a, b]
		};
		return items
	},
	buildDockedItems: function() {
		items = {
			xtype: "toolbar",
			dock: "bottom",
			items: [{
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.totalAssigned"),
				name: "totalAssigned",
				id: "totalAssignedField",
				labelWidth: 80,
				labelAlign: "left",
				value: "",
				width: 140
			}, {
				xtype: "checkboxfield",
				fieldLabel: bundle.getMsg("salesOrder.exceedQuantity"),
				name: "exceedValue",
				id: "exceedValueField",
				labelAlign: "left",
				labelWidth: 150,
				hidden: this.buttonId == "onRemoveSerial",
				readOnly: true
			}, "->",
			{
				text: bundle.getMsg("socontrol.reset"),
				id: "reset"
			}, {
				text: bundle.getMsg("socontrol.selectAll"),
				id: "selectAll" + this.buttonId
			}, {
				id: this.buttonId,
				name: this.buttonId,
				action: this.buttonId,
				text: "Ok",
				disabled: true
			}, {
				action: "cancel",
				text: "Close",
				handler: function(a) {
					a.up("window").close()
				}
			}]
		};
		return items
	},
	validList: function() {
		var f = Ext.getCmp("serialList").getValue().trim(),
			h = f.split("\n"),
			g = parseInt(Ext.getCmp("quantityField").getValue()),
			c = parseInt(Ext.getCmp("unitsQtyField").getValue()),
			b = Ext.getCmp("addmultipleserialwindow").buttonId,
			e = Ext.getCmp(b);
		if (h == 0) {
			e.setDisabled(true);
			return true
		}
		if (b == "onAddSerial") {
			if (h.length > (g - c) && !canExceedsQty) {
				e.setDisabled(true);
				return bundle.getMsg("error.salesOrder.assignSnToSalesOrder.qty")
			} else {
				e.setDisabled(false);
				return true
			}
		} else {
			if (b == "onRemoveSerial") {
				var a = Ext.getCmp("serialGrid").getStore(),
					d = false;
				h.forEach(function(i) {
					if (i != "" && !a.findRecord("serialNumber", i.toUpperCase())) {
						d = true
					}
				});
				if (h.length > c) {
					e.setDisabled(true);
					return bundle.getMsg("error.salesOrder.removeSnToSalesOrder")
				} else {
					if (d) {
						return bundle.getMsg("Not available Serial Number")
					} else {
						e.setDisabled(false);
						return true
					}
				}
			} else {
				return true
			}
		}
	}
});
Ext.define("SO.model.ErrorListModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "value",
		type: "string"
	}, {
		name: "errorMsg",
		type: "string"
	}, {
		name: "param",
		type: "string"
	}]
});
Ext.define("SO.Custom.ErrorListWindow", {
	extend: Ext.window.Window,
	alias: "widget.errorlistwindow",
	id: "errorlistwindow",
	modal: true,
	constrain: true,
	renderTo: "xmain",
	title: "",
	summaryLabelText: "",
	gridHeaderValue: "Error Value",
	showErrorMsg: true,
	initComponent: function(b) {
		var a = this;
		a.width = 600;
		a.border = 0;
		a.modal = true;
		a.layout = {
			type: "hbox",
			align: "center"
		};
		a.items = a.buildPanel();
		this.callParent(b)
	},
	buildPanel: function() {
		var a = Ext.create("Ext.grid.Panel", {
			width: 580,
			maxHeight: 400,
			autoScroll: true,
			viewConfig: {
				markDirty: false
			},
			style: {
				marginTop: "10px",
				marginLeft: "5px",
				marginBottom: "5px",
				marginRight: "5px"
			},
			store: Ext.create("SO.custom.ErrorListStore"),
			id: "addserialsresultgrid",
			columns: [{
				xtype: "actioncolumn",
				align: "center",
				width: 35,
				renderer: function(e, d, c) {
					this.icon = path + "resources/images/16X16/remove.png";
					this.tooltip = bundle.getMsg("socontrol.message.error")
				}
			}, {
				header: this.gridHeaderValue,
				flex: 1,
				sortable: true,
				dataIndex: "value"
			}, {
				header: bundle.getMsg("socontrol.message.errorMessage"),
				flex: 1,
				sortable: true,
				dataIndex: "errorMsg",
				hidden: !this.showErrorMsg,
				renderer: function(g, d, c, i, f, e, h) {
					if (c.data.param != "") {
						return Ext.String.format(bundle.getMsg(c.get("errorMsg")), c.get("param"))
					} else {
						return Ext.String.format(bundle.getMsg(c.get("errorMsg")))
					}
				}
			}],
			stripeRows: true
		});
		var b = Ext.create("Ext.panel.Panel", {
			border: 0,
			width: 590,
			layout: {
				type: "vbox",
				align: "left"
			},
			items: [{
				xtype: "label",
				id: "addserialresultsummarylabel",
				margin: "5 10 0 5",
				text: this.summaryLabelText
			},
			a],
			dockedItems: {
				xtype: "toolbar",
				dock: "bottom",
				items: ["->",
				{
					text: bundle.getMsg("socontrol.close"),
					handler: function(c) {
						c.up("window").close()
					}
				}]
			}
		});
		return b
	}
});
Ext.define("SO.custom.ErrorListStore", {
	extend: Ext.data.Store,
	model: "SO.model.ErrorListModel",
	remoteSort: false,
	autoLoad: false,
	autoSync: false
});
Ext.define("SO.Custom.SerialNumberEditor", {
	extend: Ext.form.ComboBox,
	name: "serialnumber",
	alias: "widget.serialnumbereditor",
	id: "serialnumbereditor",
	displayField: "serialNumber",
	valueField: "id",
	minChars: 3,
	pageSize: 15,
	forceSelection: true,
	typeAhead: false,
	hideTrigger: true,
	anchor: "100%",
	labelAlign: "top",
	cls: "filterFieldsInlineSerial",
	labelClsExtra: "labelFilterCssSerial",
	fieldCls: "inputFilterCss",
	submitEmptyText: false,
	initComponent: function() {
		this.width = 200;
		this.fieldLabel = bundle.getMsg("socontrol.serialNumber");
		this.emptyText = bundle.getMsg("socontrol.emptyCombo");
		this.store = Ext.create("SO.store.SerialNumberStore");
		this.listConfig = {
			loadingText: bundle.getMsg("ui.lister.searching"),
			emptyText: bundle.getMsg("ui.lister.notFoundTitle")
		};
		this.callParent(arguments)
	}
});
Ext.define("SO.Custom.OrderLinePanel", {
	extend: Ext.panel.Panel,
	alias: "widget.orderpanel",
	id: "orderpanel",
	width: "100%",
	minHeight: 100,
	height: "100%",
	record: null,
	titleCollapse: true,
	collapsible: true,
	collapsed: true,
	viewOnly: false,
	initComponent: function(a) {
		this.items = this.buildPanel();
		this.dockedItems = this.buildDockedItems();
		this.on({
			afterrender: function() {
				checkPermissionsByContainer(this)
			}
		});
		this.callParent(a)
	},
	buildPanel: function() {
		var a;
		a = Ext.create("Ext.form.Panel", {
			autoWidth: true,
			autoHeight: true,
			border: 0,
			items: [this.getStandardItemsPanel(), this.getSerials()]
		});
		return a
	},
	getSerials: function() {
		var b = this;
		var a = Ext.widget("serialnumbergrid", {
			margin: "0 15 15 15",
			id: "seriallist" + b.record.data.key,
			customColumns: [{
				header: bundle.getMsg("socontrol.release.print.serialNumber"),
				flex: 1,
				dataIndex: "serialNumber",
				sortable: true
			}, {
				header: bundle.getMsg("socontrol.scanDateTime"),
				flex: 1,
				dataIndex: "dateTime",
				sortable: false
			}, {
				header: bundle.getMsg("socontrol.quantityTable"),
				flex: 1,
				dataIndex: "quantity",
				sortable: false
			}],
			selModel: Ext.create("Ext.selection.CheckboxModel", {
				mode: "MULTI",
				showHeaderCheckbox: true,
				listeners: {
					selectionchange: function(e, d) {
						var c = Ext.getCmp("removeToolbar" + b.record.data.key);
						if (d[0]) {
							c.setDisabled(false)
						} else {
							c.setDisabled(true)
						}
					}
				}
			})
		});
		return a
	},
	getStandardItemsPanel: function() {
		var a, b = this;
		a = Ext.create("Ext.form.Panel", {
			border: 0,
			id: "StandardPanel" + this.record.data.key,
			autoWidth: true,
			autoHeight: true,
			layout: {
				type: "column",
				columns: 3
			},
			bodyPadding: "15 15 15 15",
			defaults: {
				labelClsExtra: "labelFieldDisplayCss",
				columnWidth: 0.33,
				labelWidth: 140,
				labelAlign: "right"
			},
			items: [{
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.line"),
				name: "orderLine"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("socontrol.maintenance.partNumber.partNumber"),
				name: "partNumber"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.line.customerPartNumb"),
				name: "customerPart"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.line.customerPOLine"),
				name: "customerPOLine"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.line.requestDate"),
				name: "requestedDate"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.line.promisedDate"),
				name: "promisseDate"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.line.scheduledShipDate"),
				name: "scheduledShip"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.line.shipSetName"),
				name: "shipSet"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.itemTypeCode"),
				name: "itemTypeCode"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.line.moreInfo1"),
				name: "moreinfo1"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.line.moreInfo2"),
				name: "moreinfo2"
			}, {
				xtype: "displayfield",
				fieldLabel: bundle.getMsg("salesOrder.line.ediCustPartdDesc"),
				name: "ediCustPartdDesc"
			}, {
				xtype: "displayfield",
				fieldLabel: ""
			}, {
				xtype: "displayfield",
				fieldLabel: ""
			}, {
				xtype: "progressbar",
				id: "olSerialProgressBar" + b.record.data.key,
				border: 1
			}]
		});
		return a
	},
	buildDockedItems: function() {
		var a = this;
		var b = Ext.create("Ext.toolbar.Toolbar", {
			items: [{
				icon: path + "resources/images/16X16/manage.png",
				text: bundle.getMsg("Manage Serials"),
				tooltip: bundle.getMsg("Manage Serials"),
				id: "addToolbar" + a.record.data.key,
				action: "onOpenAddPanelFromInfo",
				scope: this,
				record: null,
				actionKey: "shopOrder.salesOrderBrowser.manageSerial",
				hidden: a.viewOnly
			}, {
				icon: path + "resources/images/16X16/remove.png",
				text: bundle.getMsg("socontrol.removeSerials"),
				tooltip: bundle.getMsg("socontrol.removeSerials"),
				id: "removeToolbar" + a.record.data.key,
				action: "onDeleteSerialsFromOrderLine",
				scope: this,
				record: null,
				disabled: true,
				actionKey: "shopOrder.salesOrderBrowser.removeSerial",
				hidden: a.viewOnly
			}]
		});
		return b
	}
});
Ext.define("SO.view.SalesOrder.PushSalesOrderWindow", {
	extend: Ext.window.Window,
	alias: "widget.pushsalesorderwindow",
	id: "pushsalesorderwindow",
	autoWidth: true,
	autoHeight: true,
	resizable: false,
	modal: true,
	constrain: true,
	renderTo: "xmain",
	layout: "fit",
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("salesOrder.pushsalesOrder.tittle"), a.items = a.buildItems();
		a.dockedItems = a.buildDockedItems();
		a.callParent(arguments);
		a.border = 0
	},
	buildItems: function() {
		var b = {
			xtype: "container",
			layout: {
				type: "vbox",
				align: "stretch"
			},
			width: "100%",
			border: 0,
			items: [{
				xtype: "panel",
				layout: {
					type: "column"
				},
				border: 0,
				style: {
					padding: "10px",
					marginRight: "0px"
				},
				items: [{
					xtype: "panel",
					border: 0,
					baseCls: "float_right_panel",
					items: [{
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("Sales Order"),
						labelAlign: "top",
						name: "salesOrderField",
						width: 130,
						idProperty: "salesOrderField",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.soNumber"),
						labelAlign: "top",
						name: "soNumberField",
						idProperty: "soNumberField",
						width: 130,
						id: "soNumberField",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "customtextfield",
						fieldLabel: bundle.getMsg("socontrol.partNumber"),
						labelAlign: "top",
						name: "pNumberField",
						width: 130,
						idProperty: "pNumberField",
						value: "",
						cls: "filterFieldsInline",
						labelClsExtra: "labelFilterCss",
						fieldCls: "inputFilterCss"
					}, {
						xtype: "panel",
						layout: {
							type: "vbox"
						},
						id: "painelResearchButtons",
						baseCls: "float_right_panel",
						style: {
							marginLeft: "15px"
						},
						border: 0,
						items: [{
							xtype: "hiddenfield",
							name: "soOracleFilteredHidden",
							id: "soOracleFilteredHidden",
							idProperty: "soOracleFilteredHidden",
							value: ""
						}, {
							xtype: "button",
							id: "filterFromOracle",
							text: bundle.getMsg("socontrol.filter"),
							action: "salesOrderOracleFilter",
							iconCls: "filterButtonIcon"
						}, {
							xtype: "tbspacer",
							height: 5
						}, {
							xtype: "button",
							id: "clearResearch",
							text: bundle.getMsg("socontrol.clear"),
							action: "salesOrderOracleClear",
							iconCls: "clearButtonIcon"
						}]
					}]
				}]
			}]
		};
		var d = Ext.create("Ext.selection.CheckboxModel", {
			mode: "MULTI",
			showHeaderCheckbox: true,
			listeners: {
				selectionchange: function(g, f) {
					var e = Ext.getCmp("onOK");
					if (f[0]) {
						e.setDisabled(false)
					} else {
						e.setDisabled(true)
					}
				}
			}
		});
		var c = Ext.getCmp("somainwindow");
		var a = Ext.create("Ext.grid.Panel", {
			id: "salesOrderGrid",
			width: 0.7 * c.getWidth(),
			height: 0.7 * c.getHeight(),
			columns: [{
				header: bundle.getMsg("socontrol.salesOrderNumber"),
				dataIndex: "salesOrder",
				flex: 1
			}, {
				header: bundle.getMsg("socontrol.partNumber"),
				dataIndex: "partNumber",
				flex: 1
			}, {
				header: bundle.getMsg("socontrol.soNumber"),
				dataIndex: "shopOrderNumber",
				flex: 1
			}],
			stripeRows: true,
			enableDrag: true,
			enableDrop: false,
			store: Ext.create("SO.store.SalesOrderStore"),
			stripeRows: true,
			style: {
				marginLeft: "5px",
				marginRight: "5px",
				marginBottom: "5px"
			},
			bbar: Ext.create("Ext.Custom.CustomPaging", {
				border: 0,
				store: Ext.getStore("SerialNumberStore"),
				displayInfo: false,
				beforePageText: bundle.getMsg("socontrol.page"),
				afterPageText: ""
			}),
			dockedItems: b,
			selModel: d
		});
		return a
	},
	buildDockedItems: function() {
		items = {
			xtype: "toolbar",
			dock: "bottom",
			items: [{
				id: "onOK",
				name: "onOK",
				action: "onOK",
				text: "Push",
				disabled: true
			}, {
				action: "cancel",
				text: "Close",
				handler: function(a) {
					a.up("window").close()
				}
			}]
		};
		return items
	}
});
Ext.define("SO.view.SalesOrder.RequestSalesOrderFormWindow", {
	extend: Ext.Window,
	alias: "widget.requestsalesorderformwindow",
	id: "requestsalesorderformwindow",
	isEdit: false,
	width: 450,
	height: 130,
	modal: true,
	constrain: true,
	renderTo: "xmain",
	layout: "fit",
	initComponent: function() {
		var a = this;
		a.title = bundle.getMsg("salesOrder.requestSalesOrder");
		a.items = a.buildItems();
		a.callParent(arguments)
	},
	onEnter: function(d, c, b) {
		if (c.getKey() == Ext.EventObject.ENTER) {
			var a = Ext.getCmp("requestsalesorderformwindow_request");
			if (a != null) {
				a.fireEvent("click", a)
			}
		}
	},
	buildItems: function() {
		var d = {
			specialkey: this.onEnter
		};
		var a = Ext.create("Ext.data.Store", {
			fields: ["field"],
			data: [{
				field: "Sales Order Number",
				id: "requestsalesorderformwindow_so"
			}, {
				field: "Part Number",
				id: "requestsalesorderformwindow_pn"
			}]
		});
		var c = Ext.create("Ext.form.ComboBox", {
			fieldLabel: "Choose the Field",
			store: a,
			id: "comboSalesOrderRequest",
			queryMode: "local",
			value: "requestsalesorderformwindow_pn",
			displayField: "field",
			valueField: "id"
		});
		var b = {
			xtype: "form",
			layout: "form",
			bodyPadding: "5 5 0",
			width: 350,
			fieldDefaults: {
				labelWidth: "150",
				labelAlign: "left"
			},
			defaultType: "customtextfield",
			items: [c,
			{
				id: "requestsalesorderformwindow_so",
				fieldLabel: bundle.getMsg("salesOrder.soNumber"),
				name: "salesOrder",
				maxLength: 50,
				hidden: true,
				listeners: d,
				validator: function(f) {
					var e = Ext.getCmp("requestsalesorderformwindow_pn");
					if ((!f || f == "") && (!e.getValue() || e.getValue() == "")) {
						e.markInvalid("At least one field must be filled");
						return "At least one field must be filled"
					}
					e.clearInvalid();
					return true
				}
			}, {
				id: "requestsalesorderformwindow_pn",
				fieldLabel: bundle.getMsg("socontrol.maintenance.partNumber.partNumber"),
				name: "partNumber",
				maxLength: 50,
				listeners: d,
				validator: function(f) {
					var e = Ext.getCmp("requestsalesorderformwindow_so");
					if ((!f || f == "") && (!e.getValue() || e.getValue() == "")) {
						e.markInvalid("At least one field must be filled");
						return "At least one field must be filled"
					}
					e.clearInvalid();
					return true
				}
			}],
			dockedItems: {
				xtype: "toolbar",
				dock: "bottom",
				items: ["->",
				{
					id: "requestsalesorderformwindow_request",
					action: "requestSalesOrder",
					text: bundle.getMsg("salesOrder.request")
				}, {
					action: "cancel",
					text: bundle.getMsg("socontrol.cancel")
				}]
			}
		};
		return b
	}
});
Ext.define("SO.view.CustomViewport", {
	extend: Ext.container.Container,
	alias: "widget.customviewport",
	renderTo: "xviewport",
	layout: "border",
	height: "100%",
	minHeight: 550,
	id: "xmain",
	listeners: {
		resize: function(b, d, c, a) {
			sidebar = Ext.get("sidebar-switch"), centerpanel = Ext.getCmp("centerpanel");
			if (typeof sidebar != "undefined") {
				sidebar.on("click", function(j, i, h) {
					var g = Ext.getCmp("somainwindow"),
						f = Ext.getCmp("shopordermenu");
					if (typeof g != "undefined") {
						g.setWidth(b.getWidth())
					}
					centerpanel.setWidth(b.getWidth());
					f.setWidth(b.getWidth())
				})
			}
			if (typeof mainWindow != "undefined") {
				mainWindow.doLayout()
			}
		},
		beforerender: function(a, d, c) {
			if (document.readyState == "complete") {
				Ext.Function.defer(function() {
					a.resizePanel()
				}, 500)
			} else {
				a.resizePanel();
				window.addEventListener("load", function b() {
					window.removeEventListener("load", b, false);
					Ext.Function.defer(function() {
						a.resizePanel()
					}, 500)
				})
			}
		}
	},
	initComponent: function() {
		var a = this;
		a.title = "Shop Order";
		a.items = a.buildItems();
		a.callParent(arguments)
	},
	resizePanel: function() {
		var b = Ext.getCmp("shopordermenu"),
			c = Ext.getCmp("somainwindow"),
			a = Ext.getCmp("xmain"),
			d = Ext.get("main_content"),
			e = 0;
		if (typeof d != "undefined") {
			e = d.getHeight() - 60
		}
		if (a.minHeight > e) {
			e = a.minHeight
		}
		a.setHeight(e);
		if (document.readyState == "complete") {
			if (typeof c != "undefined") {
				c.setHeight(e)
			}
			if (typeof b != "undefined") {
				b.setHeight(e)
			}
		}
	},
	buildItems: function() {
		var a = [{
			region: "center",
			xtype: "panel",
			id: "centerpanel",
			layout: "fit"
		}, {
			id: "report",
			xtype: "report"
		}];
		return a
	}
});
Ext.define("SO.store.ShopOrderReleaseStore", {
	extend: Common.store.PaggingStore,
	model: "SO.model.ShopOrderModel",
	pageSize: 50,
	remoteSort: false,
	autoLoad: false,
	autoSync: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "ShopOrderController.getShopOrderRelease"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			successProperty: "success",
			encode: false
		})
	}
});
Ext.define("SO.store.SerialNumberAssignmentStore", {
	extend: Common.store.PaggingStore,
	model: "SO.model.ShopOrderModel",
	pageSize: 50,
	remoteSort: false,
	remoteFilter: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "ShopOrderController.getShopOrderAssignment"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	}
});
Ext.define("SO.store.PrintTravelerStore", {
	extend: Common.store.PaggingStore,
	model: "SO.model.ShopOrderModel",
	pageSize: 50,
	remoteSort: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "ShopOrderController.getPrintTraveler",
			isReprint: false
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	}
});
Ext.define("SO.model.ShopOrderToClose", {
	extend: Ext.data.Model,
	fields: [{
		name: "id"
	}, {
		name: "shopOrderNumber"
	}]
});
Ext.define("SO.store.ShopOrderCloseStore", {
	extend: Common.store.PaggingStore,
	model: "SO.model.ShopOrderToClose",
	remoteSort: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		batchActions: true,
		appendId: false,
		extraParams: {
			resourceID: "ShopOrderController.getClosableShopOrders"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			allowSingle: false
		}),
		listeners: {
			exception: function(c, b, a) {
				Ext.MessageBox.show({
					title: "REMOTE EXCEPTION NUMBER",
					msg: a.getError().status + " - " + a.getError().statusText,
					icon: Ext.MessageBox.ERROR,
					buttons: Ext.Msg.OK
				})
			}
		}
	}
});
Ext.define("SO.store.SalesOrderListStore", {
	extend: Common.store.PaggingStore,
	model: "SO.model.SalesOrderModel",
	pageSize: 50,
	remoteSort: false,
	remoteFilter: false,
	autoLoad: false
});
Ext.define("SO.controller.ShopOrderController", {
	extend: Ext.app.Controller,
	stores: ["ShopOrderBrowserStore", "SerialNumberMaintenanceStore", "ShopOrderReleaseStore", "SerialNumberAssignmentStore", "PrintTravelerStore", "ShopOrderCloseStore", "SalesOrderListStore"],
	models: ["ShopOrderModel"],
	views: ["CustomViewport", "ShopOrderMenu", "SerialNumberAssignment.SerialNumberAssignmentList", "SerialNumberMaintenance.SerialNumberMaintenanceList", "SalesOrder.SalesOrderList", "SalesOrder.SalesOrderInformation", "ShopOrderBrowser.ShopOrderBrowserList", "ShopOrderRelease.ShopOrderReleaseList", "ShopOrderRelease.ShopOrderFormWindow", "RecipeDisplay.RecipeDisplay", "ShopOrderBrowser.PrintTravelerList", "ShopOrderRelease.ShopOrderCloseList", "ShopOrderMenu"],
	init: function() {
		this.control({
			"button[id=filter]": {
				click: this.doFilter
			},
			"button[id=clear]": {
				click: this.doClear
			},
			"button[action=printFiltered]": {
				click: this.doPrint
			},
			shoporderbrowserlist: {
				iconclick: this.onSoBrowserClicked
			},
			shoporderreleaselist: {
				iconclick: this.onSoReleaseClicked
			},
			salesorderlist: {
				iconclick: this.onSalesInfoClicked
			},
			"#northpanel": {
				unfloat: this.collapse
			}
		});
		Ext.EventManager.on(window, "beforeunload", function() {
			var a = Ext.ComponentQuery.query("panel[locking=true]");
			if (a != null && a.length > 0) {
				a[0].fireEvent("beforedestroy", a, null)
			}
		})
	},
	collapse: function() {},
	onSoBrowserClicked: function(b, d, a, c) {
		if (b == "info") {
			this.pushScreen("shoporderinformation", c);
			this.application.fireEvent("onShopOrderInfo", a)
		}
		if (b == "bom") {
			this.pushScreen("recipedisplay", c);
			this.application.fireEvent("onShopOrderBom", a)
		}
	},
	onSalesInfoClicked: function(a, b) {
		this.pushScreen("salesorderinformation", b);
		this.application.fireEvent("onSalesOrderInfo", a)
	},
	onSoReleaseClicked: function(b, c, a) {
		if (b == "map") {
			this.application.fireEvent("onShopOrderMapClick", a)
		}
		if (b == "release") {
			this.application.fireEvent("onShopOrderReleaseClick", a)
		}
	},
	getCustomController: function(a) {
		var b = this.getController(a);
		return b
	},
	onMenuClicked: function(a) {
		this.pushScreen(a.action, a.id)
	},
	pushScreen: function(g, b) {
		var d = Ext.getCmp("somainwindow");
		d.removeAll(true);
		var f = this.getPushScreenParams(g, b);
		var a = Ext.widget(g, f);
		d.add(a);
		var c = function() {
				Ext.getCmp("shopordermenu").show()
			};
		var e = Ext.getCmp(g).down("header");
		e.on({
			click: c
		});
		e.addCls("headertomenu");
		e.addTool({
			type: "expand",
			tooltip: "Click to expand the Menu",
			handler: c
		});
		Ext.create("Ext.tip.ToolTip", {
			target: e.id,
			html: "Click to expand the Menu"
		});
		this.afterAddScreen(g)
	},
	getPushScreenParams: function(d, a) {
		var c = null;
		if (d == "printtravelerlist") {
			var b = false;
			if (a == "reprinttravelerlistmenubtn") {
				b = true
			}
			c = {
				dockedItems: SO.view.ShopOrderBrowser.PrintTravelerList.buildFilterTopBar(b),
				store: SO.view.ShopOrderBrowser.PrintTravelerList.getPrintTravelerStore(b),
				tbar: SO.view.ShopOrderBrowser.PrintTravelerList.buildDockedItemsBar(b)
			}
		} else {
			if (d == "shopordermapping") {
				c = a
			} else {
				if (d == "shoporderinformation") {
					c = a
				} else {
					if (d == "recipedisplay") {
						c = a
					} else {
						if (d == "salesorderinformation") {
							c = a
						}
					}
				}
			}
		}
		return c
	},
	afterAddScreen: function(f) {
		var b, e, g, d;
		g = false;
		d = false;
		if (f == "serialnumbermaintenancelist") {
			g = true;
			b = Ext.getStore("SerialNumberMaintenanceStore");
			e = Ext.create("SO.model.SerialNumberMaintenanceFilterModel")
		} else {
			if (f == "shoporderbrowserlist") {
				g = true;
				b = Ext.getStore("ShopOrderBrowserStore");
				e = Ext.create("SO.model.ShopOrderBrowserFilterModel")
			} else {
				if (f == "shoporderreleaselist") {
					g = true;
					b = Ext.getStore("ShopOrderReleaseStore");
					e = Ext.create("SO.model.ShopOrderReleaseFilterModel")
				} else {
					if (f == "serialnumberassignmentlist") {
						g = true;
						b = Ext.getStore("SerialNumberAssignmentStore");
						e = Ext.create("SO.model.SerialNumberMaintenanceFilterModel")
					} else {
						if (f == "salesorderlist") {
							g = true;
							b = Ext.getStore("SalesOrderListStore");
							e = Ext.create("SO.model.SalesOrderModel")
						} else {
							if (f == "printtravelerlist") {
								g = true;
								d = true;
								b = Ext.getStore("PrintTravelerStore");
								e = Ext.create("SO.model.PrintTravelerFilterModel")
							} else {
								if (f == "shopordercloselist") {
									g = true;
									b = Ext.getStore("ShopOrderCloseStore");
									e = Ext.create("SO.model.ShopOrderCloseFiterModel")
								}
							}
						}
					}
				}
			}
		}
		if (g == true) {
			if (b.proxy.extraParams.filterModel && !d) {
				this.restorePreviousFilter(b, e);
				var c = Ext.getCmp("filter");
				if (c != null) {
					c.fireEvent("click", c)
				}
			} else {
				var a = Ext.ComponentQuery.query(f + " button[id=clear]");
				this.doClear(a[0])
			}
			this.setCommonsListeners()
		}
	},
	restorePreviousFilter: function(a, c) {
		var e = Ext.ComponentQuery.query("textfield, combobox");
		c.set(Ext.JSON.decode(a.proxy.extraParams.filterModel));
		for (var b = 0; b < e.length; b++) {
			if (e[b].idProperty != null) {
				var d = c.get(e[b].idProperty);
				if (typeof(d) != "undefined") {
					e[b].setValue(d)
				}
			}
		}
	},
	doPrint: function(b) {
		var d, c, a;
		if (b.id == "browserPrintTop" || b.id == "browserPrintBottom") {
			d = "GenerateReportController.generateFilteredSoBrowser";
			c = Ext.create("SO.model.ShopOrderBrowserFilterModel");
			a = "shoporderbrowserlist";
			this.doPrintImpl(d, c, a)
		} else {
			if (b.id == "releasePrintTop" || b.id == "releasePrintBottom") {
				d = "GenerateReportController.generateFilteredSoRelease";
				c = Ext.create("SO.model.ShopOrderReleaseFilterModel");
				a = "shoporderreleaselist";
				this.doPrintImpl(d, c, a)
			} else {
				if (b.id == "releaseCsvPrintTop" || b.id == "releaseCsvPrintBottom") {
					d = "GenerateReportController.generateFilteredSoReleaseCsv";
					c = Ext.create("SO.model.ShopOrderReleaseFilterModel");
					a = "shoporderreleaselist";
					this.doPrintImpl(d, c, a)
				} else {
					if (b.id == "assignmentPrintTop" || b.id == "assignmentPrintBottom") {
						d = "GenerateReportController.generateFilteredSnAssignment";
						c = Ext.create("SO.model.SerialNumberMaintenanceFilterModel");
						a = "serialnumberassignmentlist";
						this.doPrintImpl(d, c, a)
					} else {
						if (b.id == "salesOrderPrintTop" || b.id == "salesOrderPrintBottom") {
							d = "SalesOrderController.generateFilteredSalesOrder";
							c = Ext.create("SO.model.SalesOrderModel");
							a = "salesorderlist";
							this.doPrintImpl(d, c, a)
						} else {
							if (b.id == "serialNumberMaintenancePrintTop" || b.id == "serialNumberMaintenancePrintBottom") {
								d = "ShopOrderController.generateFilteredSerialNumberMaint";
								c = Ext.create("SO.model.SerialNumberMaintenanceFilterModel");
								a = "serialnumbermaintenancelist";
								this.doPrintImpl(d, c, a)
							}
						}
					}
				}
			}
		}
	},
	doPrintImpl: function(f, d, b) {
		var c = "";
		var a = Ext.getCmp("soFilteredHidden");
		if (a != null) {
			c = a.getValue()
		}
		var e = {
			resourceID: f,
			filterModel: c,
			url: window.windowSOContext.ajaxURL
		};
		getResourceFile(e, b, null)
	},
	doFilter: function(b) {
		var a, c;
		if (b.action == "maintenanceFilter") {
			a = Ext.getStore("SerialNumberMaintenanceStore");
			a.proxy.extraParams.resourceID = "ShopOrderController.getShopOrderMaintenance";
			c = Ext.create("SO.model.SerialNumberMaintenanceFilterModel");
			this.doFilterImpl(a, c)
		} else {
			if (b.action == "browserFilter") {
				a = Ext.getStore("ShopOrderBrowserStore");
				a.proxy.extraParams.resourceID = "ShopOrderController.getShopOrderBrowser";
				c = Ext.create("SO.model.ShopOrderBrowserFilterModel");
				this.doFilterImpl(a, c)
			} else {
				if (b.action == "releaseFilter") {
					a = Ext.getStore("ShopOrderReleaseStore");
					a.proxy.extraParams.resourceID = "ShopOrderController.getShopOrderRelease";
					c = Ext.create("SO.model.ShopOrderReleaseFilterModel");
					this.doFilterImpl(a, c)
				} else {
					if (b.action == "assignmentFilter") {
						a = Ext.getStore("SerialNumberAssignmentStore");
						c = Ext.create("SO.model.SerialNumberMaintenanceFilterModel");
						this.doFilterImpl(a, c)
					} else {
						if (b.action == "salesOrderFilter") {
							a = Ext.getStore("SalesOrderListStore");
							a.proxy.extraParams.resourceID = "SalesOrderController.getSalesOrderToUpdate";
							c = Ext.create("SO.model.SalesOrderModel");
							this.doFilterImpl(a, c)
						} else {
							if (b.action == "printTravelerFilter") {
								a = Ext.getStore("PrintTravelerStore");
								a.proxy.extraParams.resourceID = "ShopOrderController.getPrintTraveler";
								c = Ext.create("SO.model.PrintTravelerFilterModel");
								this.doFilterImpl(a, c)
							} else {
								if (b.action == "shopOrderCloseFilter") {
									a = Ext.getStore("ShopOrderCloseStore");
									c = Ext.create("SO.model.ShopOrderCloseFiterModel");
									this.doFilterImpl(a, c)
								}
							}
						}
					}
				}
			}
		}
	},
	doFilterImpl: function(b, d) {
		var e = Ext.ComponentQuery.query("textfield, combobox");
		for (var c = 0; c < e.length; c++) {
			if (e[c].idProperty != null) {
				if (e[c].xtype == "textfield" || e[c].superclass.xtype == "textfield") {
					d.set(e[c].idProperty, Ext.String.trim(e[c].getValue()))
				} else {
					d.set(e[c].idProperty, e[c].getValue())
				}
			}
		}
		b.proxy.extraParams.filterModel = Ext.JSON.encode(d.data);
		var a = Ext.getCmp("soFilteredHidden");
		if (a != null) {
			a.setValue(Ext.JSON.encode(d.data))
		}
		b.loadPage(1)
	},
	doClear: function(b) {
		var a, c;
		if (b.action == "maintenanceClear") {
			a = Ext.getStore("SerialNumberMaintenanceStore");
			a.proxy.extraParams.resourceID = "ShopOrderController.getShopOrderMaintenance";
			c = Ext.create("SO.model.SerialNumberMaintenanceFilterModel");
			this.doClearImpl(a, c)
		} else {
			if (b.action == "browserClear") {
				a = Ext.getStore("ShopOrderBrowserStore");
				a.proxy.extraParams.resourceID = "ShopOrderController.getShopOrderBrowser";
				c = Ext.create("SO.model.ShopOrderBrowserFilterModel");
				this.doClearImpl(a, c)
			} else {
				if (b.action == "releaseClear") {
					a = Ext.getStore("ShopOrderReleaseStore");
					a.proxy.extraParams.resourceID = "ShopOrderController.getShopOrderRelease";
					c = Ext.create("SO.model.ShopOrderReleaseFilterModel");
					this.doClearImpl(a, c)
				} else {
					if (b.action == "assignmentClear") {
						a = Ext.getStore("SerialNumberAssignmentStore");
						c = Ext.create("SO.model.SerialNumberMaintenanceFilterModel");
						this.doClearImpl(a, c)
					} else {
						if (b.action == "salesOrderClear") {
							a = Ext.getStore("SalesOrderListStore");
							a.proxy.extraParams.resourceID = "SalesOrderController.getSalesOrderToUpdate";
							c = Ext.create("SO.model.SalesOrderModel");
							this.doClearImpl(a, c)
						} else {
							if (b.action == "printTravelerClear") {
								a = Ext.getStore("PrintTravelerStore");
								a.proxy.extraParams.resourceID = "ShopOrderController.getPrintTraveler";
								c = Ext.create("SO.model.PrintTravelerFilterModel");
								this.doClearImpl(a, c)
							} else {
								if (b.action == "shopOrderCloseClear") {
									a = Ext.getStore("ShopOrderCloseStore");
									c = Ext.create("SO.model.ShopOrderCloseFiterModel");
									this.doClearImpl(a, c)
								}
							}
						}
					}
				}
			}
		}
	},
	doClearImpl: function(b, d) {
		var e = Ext.ComponentQuery.query("textfield, combobox");
		for (var c = 0; c < e.length; c++) {
			if (e[c].idProperty != null) {
				if (e[c].xtype == "combobox") {
					if (e[c].getStore().getCount() > 0) {
						e[c].setValue(e[c].originalValue);
						d.set(e[c].idProperty, e[c].getValue())
					}
				} else {
					e[c].setValue("");
					d.set(e[c].idProperty, e[c].getValue())
				}
			}
		}
		var a = Ext.getCmp("soFilteredHidden");
		if (a != null) {
			filterModelValue = a.setValue("")
		}
		b.proxy.extraParams.filterModel = Ext.JSON.encode(d.data);
		b.loadPage(1)
	},
	setCommonsListeners: function() {
		var b = Ext.ComponentQuery.query("textfield, combobox");
		for (var a = 0; a < b.length; a++) {
			b[a].on({
				specialkey: this.onEnter
			})
		}
	},
	onEnter: function(d, c, b) {
		if (c.getKey() == Ext.EventObject.ENTER) {
			var a = Ext.getCmp("filter");
			if (a != null) {
				a.fireEvent("click", a)
			}
		}
	}
});
Ext.define("SO.model.BomItemSubstituteTO", {
	extend: Ext.data.Model,
	fields: [{
		name: "bomPkId"
	}, {
		name: "bomItemPkId"
	}, {
		name: "substitutePkId"
	}, {
		name: "subComponentItemKey"
	}, {
		name: "subComponentItemNumber"
	}, {
		name: "subComponentItemDesc"
	}, {
		name: "subQuantity"
	}, {
		name: "active"
	}, {
		name: "idx",
		type: "int"
	}],
	idProperty: "substitutePkId"
});
Ext.define("SO.model.BomItemTO", {
	extend: Ext.data.Model,
	fields: [{
		name: "bomPkId"
	}, {
		name: "bomItemPkId"
	}, {
		name: "componentItemNumber"
	}, {
		name: "componentDescription"
	}, {
		name: "requiredQuantity"
	}, {
		name: "quantity"
	}, {
		name: "wipSupplyType"
	}, {
		name: "sequence"
	}, {
		name: "partRev"
	}, {
		name: "subAssem"
	}, {
		name: "opSeq"
	}, {
		name: "department"
	}, {
		name: "partKey"
	}, {
		name: "customerPartNumber"
	}, {
		name: "traceabilityCode",
		type: "auto"
	}, {
		name: "itemTypeKey",
		type: "int"
	}, {
		name: "idx",
		type: "int"
	}, {
		name: "assemblyItem"
	}, {
		name: "topAssemblyItem"
	}, {
		name: "lineNumber",
		type: "int"
	}, {
		name: "kvControlled",
		type: "boolean",
		defaultValue: true
	}, {
		name: "isSerialized",
		type: "boolean",
		defaultValue: false
	}, {
		name: "isSerializedOriginalValue",
		type: "boolean",
		defaultValue: false
	}],
	idProperty: "bomItemPkId",
	hasMany: [{
		model: "SO.model.BomItemSubstituteTO",
		name: "nodes"
	}]
});
Ext.define("Common.view.SelectPartNumberWindow", {
	extend: Ext.window.Window,
	alias: "widget.selectpartnumberwindow",
	id: "selectpartnumberwindow",
	width: 400,
	height: 110,
	resizable: false,
	modal: true,
	constrain: true,
	renderTo: "xmain",
	layout: "fit",
	initComponent: function() {
		this.title = bundle.getMsg("socontrol.selectPart");
		this.items = this.buildItems();
		this.buttons = this.buildButtons();
		this.callParent(arguments)
	},
	buildItems: function() {
		var a = {
			xtype: "form",
			layout: "form",
			bodyPadding: "5 5 0",
			fieldDefaults: {
				labelAlign: "right"
			},
			items: [{
				xtype: "partnumbereditor",
				name: "id",
				allowBlank: false
			}]
		};
		return a
	},
	buildButtons: function() {
		var a = [{
			text: bundle.getMsg("socontrol.ok"),
			action: "okay"
		}, {
			text: bundle.getMsg("socontrol.cancel"),
			handler: function() {
				this.up("window").close()
			}
		}];
		return a
	}
});
Ext.tip.QuickTipManager.init();
var previousRecord = "";
var allowChange = true;
Ext.define("SO.controller.RecipeDisplayController", {
	extend: Ext.app.Controller,
	views: ["RecipeDisplay.RecipeDisplay", "RecipeDisplay.SaveRecipeWindow", "Common.view.SelectPartNumberWindow", "util.AddSerialNumberWindow"],
	init: function() {
		this.control({
			"#shopordertree": {
				selectionchange: this.onTreeSelectioTrue,
				beforedeselect: this.onTreeBeforeSelect
			},
			"#serialtree": {
				selectionchange: this.onTreeSelectioFalse,
				beforedeselect: this.onTreeBeforeSelect
			},
			"#shopordertree button[action=addbomitem]": {
				click: this.onSelectNewBomItem
			},
			"#shopordertree button[action=removebomitem]": {
				click: this.onRemoveBomItem
			},
			"recipedisplay button": {
				click: this.onButtonClick
			},
			"#componentinformationform": {
				validitychange: this.onValidityChange
			},
			recipedisplay: {
				destroy: this.onDestroy
			},
			"#selectSerialWindowToSaveRecipe button[action=onSave]": {
				click: this.onChooseSerialNumberToSave
			},
			"#selectSerialWindowToSaveRecipe button[action=onCancel]": {
				click: this.onCancelChooseSerialNumberToSave
			},
			"#selectSerialWindowToSaveRecipe button[action=reset]": {
				click: this.onResetChooseSerialNumberToSave
			},
			"saverecipewindow radio": {
				change: this.onChangeSaveRecipeOption
			},
			"saverecipewindow button[action=saveRecipe]": {
				click: this.onSaveRecipeWindow
			},
			"#selectsubstitutlepartnumberwindow button[action=okay]": {
				click: this.onAddSubstitute
			},
			"#selectbomitempartnumberwindow button[action=okay]": {
				click: this.onAddBomItem
			},
			"#bomtabpanel": {
				tabchange: this.onTabChange
			},
			"#checkboxKVControll": {
				change: this.onKVControlChange,
				afterrender: this.onKVControlChange
			}
		});
		this.application.on({
			onShopOrderBom: this.onShopOrderBom,
			scope: this
		})
	},
	onKVControlChange: function(c, d, a, b) {
		Ext.getCmp("checkboxserialized").setDisabled(!c.getValue())
	},
	onTabChange: function(d, a, c, b) {
		var e = Ext.getCmp("shopordertree").getSelectionModel().getSelection()[0];
		if (typeof e != "selected") {
			this.updateRefDes(e)
		}
		a.selModel.deselectAll(true);
		c.selModel.deselectAll(true);
		cmp = Ext.getCmp("recipepanelholder");
		cmp.removeAll(true);
		previousRecord = ""
	},
	onTreeSelectioTrue: function(a, c, b) {
		allowChange = true;
		this.onTreeSelectionChange(a, c, b)
	},
	onTreeSelectioFalse: function(a, c, b) {
		allowChange = false;
		this.onTreeSelectionChange(a, c, b)
	},
	onSaveRecipe: function(a) {
		if (a.up("window").down("form").getForm().isValid()) {
			this.doSaveRecipe([])
		} else {
			Ext.Function.defer(function() {
				Ext.getCmp("devRef").focus()
			}, 150)
		}
	},
	doSaveRecipe: function(a) {
		scope: this;
		var s = this;
		var t = Ext.getCmp("shoporderOption").getValue();
		var p = Ext.getCmp("serialnotcomplete").getValue();
		var n = Ext.getCmp("serialnotreleased").getValue();
		var l = Ext.getCmp("serialnumber").getValue();
		var g = Ext.getCmp("createAssembly").getValue();
		var f = Ext.getCmp("devRef").getValue();
		if (!t && !p && !n && !l) {
			return
		}
		var k = Ext.getCmp("shopordertree");
		var r = k.getRootNode().childNodes[0];
		var b = k.getSelectionModel().getSelection()[0];
		if (b != null) {
			this.updateRecord(b)
		}
		Ext.getCmp("saverecipewindow").close();
		var o = Ext.getCmp("xmain");
		o.getEl().mask("Loading...");
		var e = Ext.create("SO.model.BomItemTO");
		var c = Ext.create("SO.model.BomItemSubstituteTO");
		var i = {
			bomItems: [],
			substitutes: [],
			refDesignators: [],
			index: 0
		};
		this.updateRefDes(b);
		i = this.transformOnListRecursive(r.childNodes, -1, i, e, c);
		var j = i.bomItems;
		var q = i.substitutes;
		var h = i.refDesignators;
		var d = Ext.getCmp("recipesoinfopanel").getForm().getRecord();
		var m = 0;
		if (d instanceof SO.model.ShopOrderInformationModel) {
			m = d.internalId
		} else {
			if (d instanceof SO.model.ShopOrderModel) {
				m = d.data.id
			}
		}
		Ext.Ajax.request({
			url: window.windowSOContext.ajaxURL,
			method: "POST",
			params: {
				shoporder: Ext.encode({
					id: m,
					shopOrderNumber: d.data.shopOrderNumber,
					bompkID: r.data.bomPkId
				}),
				bomitems: Ext.encode(j),
				substitutes: Ext.encode(q),
				refDesignators: Ext.encode(h),
				serialnumbers: Ext.encode(Ext.pluck(a, "data")),
				updatewip: p,
				updateunstarted: n,
				createassemblies: g,
				reference: f,
				resourceID: "BomController.recipeDisplay"
			},
			success: function(u) {
				o.getEl().unmask();
				s.onCloseWindow("shoporderbrowserlist", false);
				Ext.CustomMessageBox.msg("shoporderbrowserlist", bundle.getMsg("socontrol.message.successful"), bundle.getMsg("socontrol.recipe.succesfullySaved"))
			},
			failure: function(u) {
				o.getEl().unmask();
				failureHandler(u, "recipedisplay")
			}
		})
	},
	transformOnListRecursive: function(k, f, m, h, c) {
		var g = f;
		for (var e = 0; e < k.length; e++) {
			if (k[e].data.substitutePkId > 0 || k[e].data.subComponentItemKey > 0) {
				var a = k[e];
				a.set("idx", f);
				m.substitutes.push(this.getData(a, c))
			} else {
				g++;
				var l = k[e];
				l.set("idx", g);
				m.bomItems.push(this.getData(l, h));
				for (var d = 0; d < l.data.referenceDesignators.length; d++) {
					var b = l.data.referenceDesignators[d];
					b.idx = g;
					m.refDesignators.push(b)
				}
				if (l.childNodes.length > 0) {
					m = this.transformOnListRecursive(l.childNodes, g, m, h, c);
					g = m.index
				}
			}
		}
		m.index = g;
		return m
	},
	onValidityChange: function(c, b, a) {
		previousRecord = c.getRecord()
	},
	onDestroy: function(b, a) {
		previousRecord = ""
	},
	onShopOrderBom: function(a) {
		var c = Ext.getCmp("xmain");
		c.getEl().mask("Loading ...");
		var b = 0;
		if (a instanceof SO.model.ShopOrderInformationModel) {
			b = a.internalId
		} else {
			if (a instanceof SO.model.ShopOrderModel) {
				b = a.get("id")
			}
		}
		Ext.Ajax.request({
			scope: this,
			type: "ajax",
			url: window.windowSOContext.ajaxURL,
			method: "GET",
			format: "json",
			params: {
				shopOrdeKey: b,
				bompkID: a.get("bompkID"),
				resourceID: "BomController.findRecipe"
			},
			success: function(e) {
				var g = Ext.decode(e.responseText);
				bom = g.shopOrderBom, bomSn = g.serialBoms;
				this.applyRawProperty(bom);
				Ext.getCmp("shopordertree").getStore().getRootNode().appendChild(g.shopOrderBom);
				if (g.serialBoms != null && g.serialBoms.length > 0) {
					for (var f = 0; f < g.serialBoms.length; f++) {
						this.applyRawProperty(g.serialBoms[f])
					}
					Ext.getCmp("serialtree").getStore().getRootNode().appendChild(g.serialBoms);
					this.application.fireEvent("onCompleteAppendSerialTree", Ext.getCmp("serialtree"))
				}
				c.getEl().unmask()
			},
			failure: function(e) {
				failureHandler(e, "recipedisplay");
				c.getEl().unmask()
			}
		});
		var d = Ext.getCmp("recipesoinfopanel");
		if (a instanceof SO.model.ShopOrderModel) {
			a.set("partNumber", a.getPartNumber().get("partNumber"))
		}
		d.loadRecord(a)
	},
	applyRawProperty: function(b) {
		if (typeof(b) == "undefined") {
			return
		}
		if (b.nodes != null && b.nodes.length > 0) {
			for (var a = 0; a < b.nodes.length; a++) {
				this.applyRawProperty(b.nodes[a])
			}
		}
		if (b.nodesBomItem != null && b.nodesBomItem.length > 0) {
			for (var a = 0; a < b.nodesBomItem.length; a++) {
				this.applyRawProperty(b.nodesBomItem[a])
			}
		}
		b.myraw = b
	},
	onSaveRecipeWindow: function(a) {
		this.onSaveRecipe(a)
	},
	getData: function(e, c) {
		var b = {};
		for (var a = 0; a < c.fields.keys.length; a++) {
			var d = c.fields.keys[a];
			b[d] = e.get(d)
		}
		return b
	},
	onSelectNewBomItem: function() {
		if (!this.validateNewBom(true)) {
			return
		}
		var a = Ext.widget("selectpartnumberwindow", {
			id: "selectbomitempartnumberwindow"
		});
		a.down("form").getForm().isValid();
		a.show()
	},
	onAddBomItem: function() {
		var f = Ext.getCmp("selectbomitempartnumberwindow"),
			a = f.down("form").getForm(),
			h = a.findField("id").getStore().getById(a.getValues().id),
			i = Ext.getCmp("shopordertree"),
			c = i.getRootNode().childNodes[0],
			e = i.getSelectionModel().getSelection()[0],
			d = false,
			g = "";
		if (a.isValid()) {
			if (typeof(e) != "undefined" && Ext.isEmpty(e.get("bomNo"))) {
				g = e
			} else {
				g = c
			}
			d = this.isDuplicated(g, h.get("partNumber").toUpperCase());
			if (d) {
				Ext.CustomMessageBox.msg("recipedisplay", bundle.getMsg("socontrol.message.error"), bundle.getMsg("error.progress.nextgen.bomItemDuplicated"));
				return
			}
			var b = Ext.create("SO.model.BomItemModel");
			Ext.data.NodeInterface.decorate(b);
			b = Ext.create("SO.model.BomItemModel");
			b.set("bomItemPkId", 0);
			b.set("partKey", h.get("id"));
			b.set("componentItemNumber", h.get("partNumber"));
			b.set("componentDescription", h.get("description"));
			b.set("wipSupplyType", "PULL");
			b.set("active", true);
			b.set("referenceDesignators", []);
			if (g == c) {
				b.set("topAssemblyItem", h.get("partNumber"));
				b.set("assemblyItem", h.get("partNumber"))
			} else {
				b.set("topAssemblyItem", e.get("topAssemblyItem"));
				b.set("assemblyItem", e.get("componentItemNumber"));
				b.set("lineNumber", e.get("lineNumber"))
			}
			if (this.appendChildOnTree(i, g, b)) {
				f.close()
			}
		}
	},
	isDuplicated: function(a, c) {
		if (a.get("componentItemNumber") != undefined && a.get("componentItemNumber").toUpperCase() == c) {
			return true
		}
		var b = a.findChild("componentItemNumber", c);
		if (b == null) {
			return (a.findChild("subComponentItemNumber", c) != null)
		} else {
			return true
		}
	},
	onRemoveBomItem: function() {
		var a = Ext.getCmp("shopordertree").getSelectionModel();
		var b = a.getSelection()[0];
		cmp = Ext.getCmp("recipepanelholder");
		cmp.removeAll(true);
		previousRecord = "";
		b.remove();
		a.deselect(b)
	},
	onAddSubstitute: function() {
		var g = Ext.getCmp("selectsubstitutlepartnumberwindow");
		var f = g.down("form").getForm();
		var e = f.findField("id").getStore().getById(f.getValues().id);
		var b = Ext.getCmp("shopordertree");
		var d = b.getSelectionModel().getSelection()[0];
		var c = this.isDuplicated(d, e.get("partNumber").toUpperCase());
		if (c) {
			Ext.CustomMessageBox.msg("recipedisplay", bundle.getMsg("socontrol.message.error"), bundle.getMsg("error.progress.nextgen.bomItemDuplicated"));
			return
		}
		var a = Ext.create("SO.model.BomItemSubstituteModel");
		Ext.data.NodeInterface.decorate(a);
		a = Ext.create("SO.model.BomItemSubstituteModel");
		a.set("substitutePkId", 0);
		a.set("bomItemPkId", d.get("bomItemPkId"));
		a.set("subComponentItemKey", e.get("id"));
		a.set("subComponentItemNumber", e.get("partNumber"));
		a.set("subComponentItemDesc", e.get("description"));
		if (this.appendChildOnTree(b, d, a)) {
			g.close()
		}
	},
	appendChildOnTree: function(b, a, c) {
		if (a.isLeaf()) {
			a.set("leaf", false);
			a.set("loaded", true)
		}
		var d = a.appendChild(c);
		if (d != null) {
			b.getView().refresh();
			a.expand();
			b.getSelectionModel().select(d);
			return true
		} else {
			return false
		}
	},
	onButtonClick: function(d) {
		if (d.action == "compsubstitute") {
			if (this.validateNewBom(true) == false) {
				return
			}
			var f = Ext.widget("selectpartnumberwindow", {
				id: "selectsubstitutlepartnumberwindow"
			});
			f.down("form").getForm().isValid();
			f.show()
		}
		if (d.action == "shoporderbrowser") {
			this.onCloseWindow("shoporderbrowserlist", true)
		}
		if (d.action == "cancelcompinfo") {
			var e = Ext.getCmp("shopordertree").selModel.selected.items[0];
			d.up("form").getForm().loadRecord(e)
		}
		if (d.action == "cancelsubst") {
			var e = Ext.getCmp("shopordertree").selModel.selected.items[0];
			d.up("form").getForm().loadRecord(e)
		}
		if (d.action == "saverecipe") {
			if (this.validateNewBom(false)) {
				Ext.widget("saverecipewindow").show();
				Ext.Function.defer(function() {
					Ext.getCmp("devRef").focus()
				}, 50)
			}
		}
		var c = Ext.getCmp("componentinfogrid");
		if (typeof c == "undefined") {
			return
		}
		var b = c.getStore();
		if (d.action == "addRef") {
			var e = Ext.getCmp("shopordertree").selModel.selected.items[0];
			var a = Ext.create("SO.model.RefDesignatorModel");
			b.add(a);
			if (typeof c.plugins[0] != "undefined") {
				c.plugins[0].startEdit(a, 0)
			}
		}
		if (d.action == "deleteRef") {
			b.remove(c.getSelectionModel().getSelection()[0])
		}
	},
	onChangeSaveRecipeOption: function(g, b, a, f) {
		if (g.inputValue == "serialnumber" && b == true) {
			var c = g.up("window").down("form").getForm();
			if (c.isValid()) {
				var i = Ext.widget("addserialnumberwindow", {
					id: "selectSerialWindowToSaveRecipe",
					closable: false,
					title: bundle.getMsg("socontrol.selectSNRecipe"),
					listeners: {
						afterrender: function() {
							var n = this;
							var m = Ext.create("Ext.panel.Tool", {
								type: "close",
								handler: function() {
									Ext.getCmp("serialnumber").setValue(false);
									Ext.getCmp("shoporderOption").setValue(true);
									n.close()
								}
							});
							n.header.insert(2, m)
						}
					}
				});
				var d = Ext.getCmp("selected");
				var e = Ext.create("SO.store.SerialNumberStore");
				d.reconfigure(e);
				var h = Ext.getCmp("results");
				var k = Ext.getCmp("recipesoinfopanel").getForm().getRecord();
				var j = Ext.create("SO.store.SerialNumberStore");
				var l = 0;
				if (k instanceof SO.model.ShopOrderInformationModel) {
					l = k.internalId
				} else {
					if (k instanceof SO.model.ShopOrderModel) {
						l = k.data.id
					}
				}
				j.proxy.extraParams.shopOrderId = l;
				j.proxy.extraParams.resourceID = "SerialNumberController.getFindAllSerialNumberView";
				j.proxy.extraParams.ignoreLimit = true;
				j.load();
				h.reconfigure(j);
				i.show()
			} else {
				g.setValue(false);
				Ext.Function.defer(function() {
					Ext.getCmp("devRef").focus();
					Ext.getCmp("shoporderOption").setValue(true)
				}, 100)
			}
		}
	},
	onChooseSerialNumberToSave: function(a) {
		var b = Ext.getCmp("selected").getStore();
		if (b.getRange().length < 1) {
			return
		}
		Ext.getCmp("selectSerialWindowToSaveRecipe").close();
		this.doSaveRecipe(b.getRange())
	},
	onCancelChooseSerialNumberToSave: function() {
		Ext.getCmp("selectSerialWindowToSaveRecipe").close();
		Ext.getCmp("serialnumber").setValue(false);
		Ext.getCmp("shoporderOption").setValue(true)
	},
	onResetChooseSerialNumberToSave: function() {
		Ext.getCmp("results").store.load();
		Ext.getCmp("selected").store.removeAll()
	},
	updateRefDes: function(a) {
		if (typeof a == "undefined") {
			return
		}
		var c = Ext.getCmp("componentinfogrid");
		if (typeof c == "undefined") {
			return
		}
		var b = c.getStore();
		a.data.referenceDesignators = Ext.pluck(b.data.items, "data")
	},
	onTreeBeforeSelect: function(d, a, b, c) {
		if (a == previousRecord) {
			this.updateRecord(a)
		}
		this.updateRefDes(a);
		return this.validateNewBom(true)
	},
	updateRecord: function(c) {
		var b = null,
			g = null;
		if (c) {
			if (typeof(c.get("substitutePkId")) != "undefined") {
				b = SO.model.BomItemSubstituteTO.prototype.fields.items;
				g = Ext.getCmp("componentinformationform").getForm()
			} else {
				if (typeof(c.get("bomItemPkId")) != "undefined") {
					b = SO.model.BomItemTO.prototype.fields.items;
					g = Ext.getCmp("componentinformationform").getForm()
				}
			}
			if (b != null && g != null) {
				var d = g.getFieldValues(),
					h = {},
					f = 0,
					a = b.length,
					e;
				for (; f < a; ++f) {
					e = b[f].name;
					if (d.hasOwnProperty(e)) {
						h[e] = d[e]
					}
				}
				c.set(h)
			}
		}
	},
	validateNewBom: function(c) {
		var b = Ext.getCmp("componentinformationform");
		if (typeof(b) != "undefined") {
			if (!b.getForm().isValid()) {
				var a = Ext.getCmp("shopordertree").getSelectionModel();
				a.select(previousRecord);
				return false
			}
		}
		return true
	},
	onTreeSelectionChange: function(k, c, g) {
		var e = c[0];
		var i = Ext.ComponentQuery.query("#shopordertree button[action=removebomitem]")[0];
		cmp = Ext.getCmp("recipepanelholder");
		cmp.removeAll(true);
		if (e == null) {
			i.setDisabled(true);
			return
		}
		if (i != null) {
			i.setDisabled(e.data.depth < 2)
		}
		if (typeof(e.get("substitutePkId")) != "undefined") {
			cmp.add(SO.view.ShopOrderBrowser.RecipePanels.getSubstitutePanel());
			Ext.getCmp("componentinformationform").loadRecord(e);
			Ext.getCmp("parentsubstform").loadRecord(e.parentNode);
			Ext.tip.QuickTipManager.unregister("qtytextfield");
			if (!allowChange) {
				Ext.getCmp("qtytextfield").setDisabled(true)
			}
		} else {
			if (typeof(e.get("bomItemPkId")) != "undefined") {
				var d = SO.view.ShopOrderBrowser.RecipePanels.getComponentPanel(),
					b = Ext.getCmp("itemTypeCombo");
				if (e.get("bomItemPkId") != 0) {
					d.getForm().getFields().each(function(l) {
						if (l.keep_enabled != true && (l.isXType("customtextfield", true) || l.isXType("combobox", true) || l.isXType("checkbox", true) || l.isXType("pnrecipeeditor", true))) {
							l.setReadOnly(true);
							l.fieldCls = "readOnly"
						}
					});
					Ext.define("ItemTypeModel", {
						extend: Ext.data.Model,
						fields: ["itemTypeKey", "itemType"]
					});
					b.getStore().add(Ext.create("ItemTypeModel", {
						itemTypeKey: e.get("itemTypeKey"),
						itemType: e.get("itemType")
					}))
				} else {
					b.getStore().load()
				}
				cmp.add(d);
				checkPermissionsByContainer(d);
				Ext.getCmp("componentinformationform").loadRecord(e);
				var f = (((typeof e.get("wipSupplyType")) != "undefined" && e.get("wipSupplyType") != null) ? e.get("wipSupplyType") : "").toUpperCase().indexOf("PULL") != -1;
				if (!allowChange || (f && e.get("bomItemPkId") > 0)) {
					var j = Ext.getCmp("qtytextfield");
					j.setReadOnly(true);
					if (f) {
						Ext.tip.QuickTipManager.register({
							target: "qtytextfield",
							text: 'It is not allowed to change the quantity for "PULL" Supply Types.'
						})
					}
				} else {
					Ext.tip.QuickTipManager.unregister("qtytextfield")
				}
				var a = Ext.getCmp("componentinfogrid");
				var h = a.getStore();
				h.loadData(e.data.referenceDesignators != null ? e.data.referenceDesignators : {})
			} else {
				if (typeof(e.get("bomPkId")) != "undefined" && e.get("bomPkId") != "") {
					cmp.add(SO.view.ShopOrderBrowser.RecipePanels.getRootPanel());
					Ext.getCmp("sobomdeviationinfoform").loadRecord(e)
				} else {
					cmp.add(SO.view.ShopOrderBrowser.RecipePanels.getRootPanel());
					if (e.childNodes.length > 0) {
						Ext.getCmp("sobomdeviationinfoform").loadRecord(e.parentNode)
					} else {
						Ext.getCmp("sobomdeviationinfoform").loadRecord(e.parentNode.parentNode)
					}
				}
			}
		}
	},
	onCloseWindow: function(b, a) {
		previousRecord = "";
		var c = this;
		if (a) {
			Ext.Msg.show({
				title: bundle.getMsg("socontrol.confirm"),
				msg: bundle.getMsg("socontrol.message.confirm.cancel"),
				buttons: Ext.Msg.YESNO,
				icon: Ext.Msg.QUESTION,
				fn: function(d) {
					if (d == "yes") {
						c.application.controllers.get("ShopOrderController").pushScreen(b)
					}
				}
			})
		} else {
			c.application.controllers.get("ShopOrderController").pushScreen(b)
		}
	}
});
Ext.define("SO.controller.SerialNumberAssignmentController", {
	extend: Ext.app.Controller,
	stores: ["SerialNumberAssignmentStore", "SerialNumberStore"],
	models: ["ShopOrderModel", "SerialNumberModel", "SerialNumberAssignmentFilterModel"],
	views: ["SerialNumberAssignment.SerialNumberAssignmentList", "SerialNumberAssignment.SerialNumberAssignmentFilter", "util.RemoveSerialNumberWindow", "util.RemoveMultipleSerialNumbersWindow", "util.AddSerialNumberWindow", "util.AddMultipleSerialNumbersWindow"],
	remainingQty: 0,
	init: function() {
		this.control({
			"serialnumberassignmentlist button[action=onOpenAddPanelFromList]": {
				click: this.onOpenAssignPanelFromList
			},
			"serialnumberassignmentlist button[action=onOpenRemovePanelFromList]": {
				click: this.onOpenRemovePanelFromList
			},
			"serialnumberassignmentlist button[action=printExportAssignmentList]": {
				click: this.printExportAssignmentList
			},
			"#addfromassignment grid[id=results]": {
				scope: this,
				itemdblclick: function(g, f, c, a, d, b) {
					toStore = Ext.getCmp("selected").store;
					if (a > -1 && this.remainingQty > toStore.getCount()) {
						this.itemDoubleClick(Ext.getCmp("results").store, Ext.getCmp("selected").store, f)
					}
				}
			},
			"#addfromassignment grid[id=selected]": {
				scope: this,
				itemdblclick: function(g, f, c, a, d, b) {
					if (a > -1) {
						this.itemDoubleClick(Ext.getCmp("selected").store, Ext.getCmp("results").store, f)
					}
				}
			},
			"#removefromassignment grid[id=removable]": {
				scope: this,
				itemdblclick: function(g, f, c, a, d, b) {
					if (a > -1) {
						this.itemDoubleClick(Ext.getCmp("removable").store, Ext.getCmp("selected").store, f)
					}
				}
			},
			"#removefromassignment grid[id=selected]": {
				scope: this,
				itemdblclick: function(g, f, c, a, d, b) {
					if (a > -1) {
						this.itemDoubleClick(Ext.getCmp("selected").store, Ext.getCmp("removable").store, f)
					}
				}
			},
			"#removefromassignment button[action=onSave]": {
				click: this.onSaveRemove
			},
			"#addfromassignment button[action=onSave]": {
				click: this.onSaveAdd
			},
			"#removefromassignment button[action=onCancel]": {
				click: this.onRemoveCancel
			},
			"#addfromassignment button[action=onCancel]": {
				click: this.onAddCancel
			},
			"#removefromassignment button[action=onRemoveMultiple]": {
				click: this.onRemoveMultiple
			},
			"#addfromassignment button[action=onAddMultiple]": {
				click: this.onAddMultiple
			},
			"#removefromassignment textfield[id=findSNToSelect]": {
				keypress: function(b, a) {
					if (a.getKey() == Ext.EventObject.ENTER && b.value != null && b.value != "") {
						this.findSNRemoveToSelect(b.getValue())
					}
				}
			},
			"#addfromassignment textfield[id=findSNToSelect]": {
				keypress: function(b, a) {
					if (a.getKey() == Ext.EventObject.ENTER && b.value != null && b.value != "") {
						this.findSNAddToSelect(b.getValue())
					}
				}
			},
			"#removefromassignment textfield[id=findSNByTypeToSelect]": {
				keyup: function(b, a) {
					this.findSNByTypeRemoveToSelect(b.getValue())
				}
			},
			"#addfromassignment textfield[id=findSNByTypeToSelect]": {
				keyup: function(b, a) {
					this.findSNByTypeAddToSelect(b.getValue())
				}
			},
			"#removefromassignment button[action=reset]": {
				click: this.resetFromRemoveFromAssignmentScreen
			},
			"#addfromassignment button[action=reset]": {
				click: this.resetFromAddFromAssignmentScreen
			},
			"#removemultiplefromassignment button[action=onOkRemoveMultipleSN]": {
				click: this.onOkRemoveMultipleSN
			},
			"#addmultiplefromassignment button[action=onOkAddMultipleSN]": {
				click: this.onOkAddMultipleSN
			},
			"#removemultiplefromassignment button[action=onCancelRemoveMultipleSN]": {
				click: this.onCancelRemoveMultipleSN
			},
			"#addmultiplefromassignment button[action=onCancelAddMultipleSN]": {
				click: this.onCancelAddMultipleSN
			}
		})
	},
	resetFromAddFromAssignmentScreen: function() {
		Ext.getCmp("results").store.load();
		Ext.getCmp("selected").store.removeAll();
		this.changeRemainingQty()
	},
	resetFromRemoveFromAssignmentScreen: function() {
		Ext.getCmp("removable").store.load();
		Ext.getCmp("selected").store.removeAll()
	},
	findSNByTypeRemoveToSelect: function(b) {
		b = Ext.String.trim(b);
		var a = Ext.getCmp("removable").store;
		a.filter("serialNumber", b);
		a.clearFilter(true)
	},
	findSNByTypeAddToSelect: function(b) {
		b = Ext.String.trim(b);
		var a = Ext.getCmp("results").store;
		a.filter("serialNumber", b);
		a.clearFilter(true)
	},
	findSNRemoveToSelect: function(c) {
		var a = Ext.getCmp("removable").store;
		var b = a.findExact("serialNumber", c.toUpperCase());
		if (b != -1) {
			var d = a.getAt(b);
			a.remove(d);
			var e = Ext.getCmp("selected").store;
			e.add(d)
		} else {
			Ext.CustomMessageBox.msg("removefromassignment", bundle.getMsg("socontrol.message.error"), Ext.String.format(bundle.getMsg("socontrol.maintenance.message.serialNumberIsNotInRemovableList"), c.toUpperCase()))
		}
		Ext.getCmp("findSNToSelect").setValue("")
	},
	findSNAddToSelect: function(d) {
		d = Ext.String.trim(d);
		var a = Ext.getCmp("results").store,
			f = Ext.getCmp("selected").store;
		var b = a.findExact("serialNumber", d.toUpperCase());
		var c = f.findExact("serialNumber", d.toUpperCase());
		if (b != -1) {
			var e = a.getAt(b);
			a.remove(e);
			f.add(e)
		} else {
			if (c == -1) {
				var e = Ext.create("SO.model.SerialNumberModel");
				e.set("serialNumber", d.toUpperCase());
				f.add(e)
			}
		}
		Ext.getCmp("findSNToSelect").setValue("")
	},
	onOpenAssignPanelFromList: function() {
		var a = Ext.getCmp("serialnumberassignmentlist");
		var i = a.getSelectionModel().getSelection();
		var d = i[0];
		if (d) {
			var c = Ext.widget("addserialnumberwindow", {
				id: "addfromassignment",
				title: bundle.getMsg("socontrol.assignSerialNumber")
			});
			var f = Ext.getCmp("results");
			var h = Ext.getStore("SerialNumberStore");
			h.proxy.extraParams.partKey = d.get("partId");
			h.proxy.extraParams.resourceID = "SerialNumberController.addAssignSerialNumber";
			f.reconfigure(h);
			h.load();
			var b = Ext.getCmp("selected");
			var e = Ext.create("SO.store.SerialNumberStore");
			b.reconfigure(e);
			this.remainingQty = d.data.remainingQuantity;
			var g = c.title + " - " + bundle.getMsg("socontrol.soNumber") + ": " + d.data.shopOrderNumber + " - " + bundle.getMsg("socontrol.remainingQty") + ": " + this.remainingQty;
			c.setTitle(g);
			this.addListenerDataChangedToStore(e);
			c.show();
			Ext.Function.defer(function() {
				Ext.getCmp("findSNToSelect").focus()
			}, 50)
		}
	},
	onOpenRemovePanelFromList: function() {
		var d = Ext.getCmp("serialnumberassignmentlist");
		var f = d.getSelectionModel().getSelection();
		var a = f[0];
		if (a) {
			var c = Ext.widget("removeserialnumberwindow", {
				id: "removefromassignment",
				hasNonSerBatch: a.get("hasNonSerBatch")
			});
			var g = Ext.getCmp("removable");
			var b = Ext.create("SO.store.SerialNumberStore");
			g.reconfigure(b);
			b.proxy.extraParams.shopOrderId = a.getId();
			b.getProxy().extraParams.resourceID = "SerialNumberController.findAssignedSerialNumbers";
			b.load({
				callback: function() {
					var i = c.title + " - " + bundle.getMsg("socontrol.soNumber") + ": " + a.data.shopOrderNumber;
					c.setTitle(i)
				}
			});
			var e = Ext.getCmp("selected");
			var h = Ext.create("SO.store.SerialNumberStore");
			e.reconfigure(h);
			c.show();
			Ext.Function.defer(function() {
				Ext.getCmp("findSNToSelect").focus()
			}, 50)
		}
	},
	printExportAssignmentList: function() {
		var c = Ext.getCmp("serialnumberassignmentlist");
		var d = c.getSelectionModel().getSelection();
		var a = d[0];
		if (a) {
			var b = "serialnumberassignmentlist";
			var f = "GenerateReportController.generateAssignedSerialNumbers";
			var e = {
				resourceID: f,
				shopOrder: Ext.JSON.encode(a.data),
				partNumber: a.getPartNumber().get("partNumber")
			};
			getResourceFile(e, b, null)
		}
	},
	onSaveAdd: function() {
		var a = Ext.getCmp("selected").getStore();
		if (a.getCount() <= this.remainingQty) {
			this.doSave("add")
		} else {
			Ext.CustomMessageBox.msg("addfromassignment", bundle.getMsg("socontrol.message.error"), bundle.getMsg("socontrol.maintenance.message.toManySerialNumbersWereSelected"))
		}
	},
	onSaveRemove: function() {
		this.doSave("remove")
	},
	doSave: function(e) {
		var f = Ext.getCmp("selected"),
			h = f.getStore();
		if (h.getCount() < 1) {
			var d = "";
			if (e == "remove") {
				d = "removefromassignment"
			} else {
				if (e == "add") {
					d = "addfromassignment"
				}
			}
			Ext.CustomMessageBox.msg(d, bundle.getMsg("socontrol.message.error"), bundle.getMsg("error.progress.socontrol.serialNumberNotSelected"));
			return
		}
		var a = Ext.getCmp("serialnumberassignmentlist"),
			j = a.getSelectionModel().getSelection(),
			g = j[0],
			k = "[]",
			b = "[]",
			c = "[]",
			i = null;
		if (e == "remove") {
			if (f.plugins[0]) {
				f.plugins[0].completeEdit()
			}
			if (j[0].get("hasNonSerBatch")) {
				c = Ext.encode(Ext.pluck(h.getRange(), "data"))
			} else {
				b = Ext.encode(Ext.pluck(h.getRange(), "data"))
			}
			i = Ext.getCmp("removefromassignment")
		} else {
			if (e == "add") {
				k = Ext.encode(Ext.pluck(h.getRange(), "data"));
				i = Ext.getCmp("addfromassignment")
			}
		}
		i.getEl().mask("Saving ...");
		Ext.Ajax.request({
			scope: this,
			url: window.windowSOContext.ajaxURL,
			params: {
				resourceID: "SerialNumberController.saveSerialNumbersForShopOrder",
				shopOrderId: g.getId(),
				isAssign: true,
				toAdd: k,
				toRemove: b,
				toDecrease: c
			},
			success: function(l) {
				i.getEl().unmask();
				h.removeAll();
				i.close();
				Ext.CustomMessageBox.msg("serialnumberassignmentlist", bundle.getMsg("socontrol.message.successful"), bundle.getMsg("socontrol.serialnumber.successfullyAssignedSaved"));
				this.refreshGrid()
			},
			failure: function(l) {
				i.getEl().unmask();
				failureHandler(l, i.id)
			}
		})
	},
	onOkRemoveMultipleSN: function() {
		var c = Ext.getCmp("removemultiplefromassignment").down("textareafield").getRawValue();
		if (c != "") {
			var a = c.split("\n");
			var b;
			for (b = 0; b < a.length; b++) {
				if (a[b] != "") {
					this.findSNRemoveToSelect(a[b])
				}
			}
			Ext.getCmp("removemultiplefromassignment").close()
		}
	},
	onOkAddMultipleSN: function() {
		var c = Ext.getCmp("addmultiplefromassignment").down("textareafield").getRawValue();
		if (c != "") {
			var a = c.split("\n");
			var b;
			for (b = 0; b < a.length; b++) {
				if (a[b] != "") {
					this.findSNAddToSelect(a[b])
				}
			}
			Ext.getCmp("addmultiplefromassignment").close()
		}
	},
	onCancelRemoveMultipleSN: function() {
		Ext.getCmp("removemultiplefromassignment").close()
	},
	onCancelAddMultipleSN: function() {
		Ext.getCmp("addmultiplefromassignment").close()
	},
	onRemoveCancel: function() {
		Ext.getCmp("removefromassignment").close()
	},
	onAddCancel: function() {
		Ext.getCmp("addfromassignment").close()
	},
	onRemoveMultiple: function() {
		Ext.widget("removemultipleserialnumberswindow", {
			id: "removemultiplefromassignment"
		}).show();
		Ext.Function.defer(function() {
			Ext.getCmp("multipleSnArea").focus()
		}, 50)
	},
	onAddMultiple: function() {
		Ext.widget("addmultipleserialnumberswindow", {
			id: "addmultiplefromassignment"
		}).show();
		Ext.Function.defer(function() {
			Ext.getCmp("multipleSnArea").focus()
		}, 50)
	},
	changeRemainingQty: function() {
		var f = this.remainingQty - Ext.getCmp("selected").store.getCount();
		var c = Ext.getCmp("serialnumberassignmentlist");
		var d = c.getSelectionModel().getSelection();
		var b = d[0];
		var e = Ext.getCmp("addfromassignment");
		title = bundle.getMsg("socontrol.addSerialNumber") + " - " + bundle.getMsg("socontrol.soNumber") + ": " + b.data.shopOrderNumber + " - " + bundle.getMsg("socontrol.remainingQty") + ": " + f;
		e.setTitle(title);
		if (f <= 0) {
			Ext.getCmp("results").getView().getPlugin("gridviewdragdrop").dragZone.lock();
			var a = Ext.getCmp("findSNToSelect");
			a.setValue("");
			a.disable();
			Ext.getCmp("findSNToSelectButton").disabled = true
		} else {
			Ext.getCmp("results").getView().getPlugin("gridviewdragdrop").dragZone.unlock();
			Ext.getCmp("findSNToSelect").enable();
			Ext.getCmp("findSNToSelectButton").disabled = false
		}
	},
	addListenerDataChangedToStore: function(a) {
		a.on({
			scope: this,
			datachanged: this.changeRemainingQty,
			clear: this.changeRemainingQty
		})
	},
	itemDoubleClick: function(a, b, c) {
		a.remove(c);
		if (c.dirty) {
			c.reject()
		}
		b.add(c)
	},
	refreshGrid: function() {
		var a = Ext.ComponentQuery.query("#serialnumberassignmentlist button[id=filter]")[0];
		if (a) {
			a.fireEvent("click", a)
		}
	}
});
Ext.define("SO.store.MappedStore", {
	extend: Ext.data.Store,
	model: "SO.model.MappingInformationModel",
	pageSize: 50,
	remoteSort: false,
	remoteFilter: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "MappingController.map"
		},
		batchActions: true,
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			messageProperty: "message",
			idProperty: "id",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: false,
			allowSingle: false
		})
	}
});
Ext.define("SO.store.LocationStore", {
	extend: Ext.data.Store,
	name: "LocationStore",
	model: "SO.model.Location",
	pageSize: 50,
	remoteSort: false,
	remoteFilter: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "MappingController.locationForMappingType"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			messageProperty: "message",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	}
});
Ext.define("SO.model.ProcessModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "processId"
	}, {
		name: "name"
	}, {
		name: "line"
	}, {
		name: "sfdcKey",
		type: "int"
	}, {
		name: "sfdcId"
	}]
});
Ext.define("SO.store.ProcessStore", {
	extend: Ext.data.Store,
	name: "ProcessStore",
	model: "SO.model.ProcessModel",
	pageSize: 50,
	remoteSort: false,
	remoteFilter: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "MappingController.getProcessForMappingType"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			messageProperty: "message",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	}
});
var operationSequenceGlobal = "";
Ext.define("SO.controller.ShopOrderReleaseController", {
	extend: Ext.app.Controller,
	stores: ["OperationSequenceStore", "LocationStore", "ProcessStore", "MappedStore"],
	views: ["ShopOrderRelease.ShopOrderReleaseList", "ShopOrderRelease.ShopOrderFormWindow", "ShopOrderRelease.SelectMappingTypeWindow", "ShopOrderRelease.ShopOrderMapping", "ShopOrderRelease.OtherMappingsAvailableWindow"],
	refs: [{
		selector: "#shoporderformwindow form",
		ref: "shopOrderForm"
	}, {
		selector: "#shoporderreleaselist",
		ref: "list"
	}],
	init: function() {
		this.control({
			"shoporderreleaselist button[action=add]": {
				click: this.onAddShopOrderClick
			},
			"shoporderreleaselist button[action=edit]": {
				click: this.onShopOrderEditClick
			},
			"shoporderreleaselist button[action=delete]": {
				click: this.onShopOrderDeleteClick
			},
			"shoporderreleaselist button[action=shopordercloselist]": {
				click: this.onShopOrderCloseClick
			},
			"shopordercloselist button[action=closeshoporders]": {
				click: this.onCloseShopOrders
			},
			"shoporderformwindow button[action=cancel]": {
				click: this.onCancelShopOrderForm
			},
			"shoporderformwindow button[action=reset]": {
				click: this.onResetShopOrderForm
			},
			"shoporderformwindow button[action=save]": {
				click: this.onSaveShopOrderForm
			},
			"shoporderformwindow partnumbereditor": {
				select: this.onPartNumberSelection
			},
			"shopordercloselist button[action=backShopOrderReleaseBottom]": {
				click: this.onBackShopOrderRelease
			},
			"shopordermapping [id=findSNByTypeOperationSequence]": {
				keyup: function(b, a) {
					this.findSNByTypeOperationSequence(b.getValue())
				}
			},
			"shopordermapping [id=findSNByTypeLocationProcess]": {
				keyup: function(b, a) {
					this.findSNByTypeLocationProcess(b.getValue())
				}
			},
			"#shopordermapping button[action=onCancelShopOrderMapping]": {
				click: this.onCancelShopOrderMapping
			},
			"#selectmappingtypewindow button[action=onOkSelectMappingType]": {
				click: this.onOkSelectMappingType
			},
			"#selectmappingtypewindow button[action=onCancelMappingType]": {
				click: this.onCancelMappingType
			},
			"#shopordermapping button[action=otherMappingsAvailable]": {
				click: this.onOtherMappingsAvailableClick
			},
			"#shopordermapping button[action=changeMappingType]": {
				click: function() {
					var a = this;
					Ext.Msg.show({
						title: bundle.getMsg("socontrol.message.information"),
						msg: bundle.getMsg("socontrol.release.mapping.changeMappingTypeMessage"),
						buttons: Ext.Msg.YESNO,
						icon: Ext.Msg.INFO,
						fn: function(c) {
							if (c == "yes") {
								var b = Ext.getCmp("shopOrderInformationPanel").getForm().getRecord();
								if (b.get("mappingTypeLabel") == bundle.getMsg("socontrol.process")) {
									b.set("mappingTypeKey", 2);
									b.set("mappingTypeLabel", bundle.getMsg("socontrol.location"))
								} else {
									if (b.get("mappingTypeLabel") == bundle.getMsg("socontrol.location")) {
										b.set("mappingTypeKey", 1);
										b.set("mappingTypeLabel", bundle.getMsg("socontrol.process"))
									}
								}
								b.set("mappingId", 0);
								a.openShopOrderMapping(b)
							}
						}
					})
				}
			},
			"#shopordermapping button[action=addMap]": {
				click: this.onAddMapClick
			},
			"#shopordermapping button[action=automaticMap]": {
				click: this.onAutomaticMapClick
			},
			"#shopordermapping button[action=onSaveShopOrderMapping]": {
				click: this.onSaveShopOrderMapping
			},
			"#shopordermapping button[action=onRemoveShopOrderMapping]": {
				click: this.onRemoveShopOrderMapping
			},
			"#othermappingsavailablewindow button[action=onCancelOtherMappingsAvailable]": {
				click: this.onCancelOtherMappingsAvailable
			},
			"#othermappingsavailablewindow button[action=onOkOtherMappingsAvailable]": {
				click: this.onOkOtherMappingsAvailable
			},
			"#othermappingsavailablewindow grid[id=othermappinggrid]": {
				itemclick: this.selectOldMapping
			}
		});
		this.application.on({
			onShopOrderMapClick: this.onShopOrderMapClick,
			scope: this
		})
	},
	onShopOrderCloseClick: function() {
		this.pushScreen("shopordercloselist")
	},
	onBackShopOrderRelease: function() {
		this.pushScreen("shoporderreleaselist")
	},
	onCloseShopOrders: function() {
		var b = Ext.getCmp("shopordercloselist");
		var c = b.getSelectionModel().getSelection();
		var a = b.getStore();
		a.remove(c);
		a.getProxy().extraParams.resourceID = "ShopOrderController.closeShopOrder";
		a.sync({
			failure: function() {
				a.getProxy().extraParams.resourceID = "ShopOrderController.getClosableShopOrders";
				a.loadPage(1)
			}
		});
		this.addListenerSuccessToStore(a, "shopordercloselist");
		addExceptionListenerOnProxy(a.getProxy(), "shopordercloselist");
		a.getProxy().extraParams.resourceID = "ShopOrderController.getClosableShopOrders"
	},
	addListenerSuccessToStore: function(b, a) {
		var c = this;
		if (b.hasListeners.write) {
			delete b.hasListeners.write
		}
		if (b.events.write) {
			delete b.events.write
		}
		b.on({
			write: function(f, e) {
				var g = Ext.decode(e.response.responseText);
				if (g.success) {
					Ext.CustomMessageBox.msg(a, bundle.getMsg("socontrol.message.successful"), bundle.getMsg(g.message));
					if (a == "shopordermapping") {
						var d = Ext.getCmp("shopOrderInformationPanel").getForm().getRecord();
						if (SO.view.util.ShopOrderUtil.isShopOrderReleasable(d.data)) {
							Ext.Msg.show({
								scope: this,
								title: bundle.getMsg("socontrol.message.information"),
								msg: bundle.getMsg("socontrol.release.mapping.releaseShopOrderAfterMapping"),
								buttons: Ext.Msg.YESNO,
								icon: Ext.Msg.INFO,
								fn: function(h) {
									if (h == "yes") {
										d.set("mappingId", g.mappingId);
										c.application.fireEvent("onShopOrderReleaseClick", d)
									}
									c.onCancelShopOrderMapping()
								}
							})
						}
					}
				}
			}
		})
	},
	refreshGrid: function() {
		var a = Ext.ComponentQuery.query("#shoporderreleasefilter button[id=filter]")[0];
		if (a) {
			a.fireEvent("click", a)
		}
	},
	onAddShopOrderClick: function() {
		Ext.widget("shoporderformwindow", {
			isEdit: false
		}).show();
		var a = Ext.create("SO.model.ShopOrderModel");
		addExceptionListenerOnProxy(a.proxy, "shoporderformwindow");
		this.getShopOrderForm().loadRecord(a);
		this.getShopOrderForm().getForm().isValid();
		Ext.Function.defer(function() {
			Ext.getCmp("shopOrderNumberField").focus()
		}, 50)
	},
	getDetails: function(a, d) {
		scope = this;
		var c = this;
		var b = Ext.ModelManager.getModel("SO.model.ShopOrderModel");
		b.getProxy().extraParams.resourceID = "ShopOrderController.findShopOrder";
		b.load(a.data.id, {
			scope: this,
			failure: function(f, e) {
				Ext.Msg.show({
					scope: this,
					title: "Error",
					msg: bundle.getMsg("error.progress.nextgen.shopOrderNotFound"),
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
				c.maskUnmask(false)
			},
			success: function(f, e) {
				if (d == "edit") {
					c.onShopOrderBeforeEditClick(f)
				}
				c.maskUnmask(false)
			}
		})
	},
	maskUnmask: function(b) {
		var a = Ext.getCmp("shoporderreleaselist");
		if (b) {
			a.getEl().mask("Loading...")
		} else {
			a.getEl().unmask()
		}
	},
	onShopOrderEditClick: function() {
		scope = this;
		this.maskUnmask(true);
		var a = this.getList().getSelectionModel().getSelection()[0];
		var b = "edit";
		this.getDetails(a, b)
	},
	onShopOrderBeforeEditClick: function(c) {
		var b = Ext.widget("shoporderformwindow", {
			isEdit: true,
			viewOnly: !checkPermission("shopOrder.shopOrderRelease.editShopOrder")
		});
		b.show();
		b.down("form").getForm().loadRecord(c);
		var a = this.getShopOrderForm().down("partnumbereditor");
		a.forceSelection = false;
		a.setEditable(false);
		a.setDisabled(true);
		a.setValue(c.getPartNumber().get("partNumber"));
		this.reloadRevisionCombo(c.get("partId"), c.get("revision"));
		addExceptionListenerOnProxy(c.proxy, "shoporderformwindow");
		Ext.Function.defer(function() {
			Ext.getCmp("shopOrderNumberField").focus()
		}, 50)
	},
	onShopOrderDeleteClick: function() {
		var a = this.getList().getSelectionModel().getSelection()[0];
		var c = Ext.String.format(bundle.getMsg("messages.confirmdelete"), a.data.shopOrderNumber);
		var b = this;
		Ext.Msg.show({
			title: bundle.getMsg("socontrol.confirm"),
			msg: c,
			buttons: Ext.Msg.YESNO,
			icon: Ext.Msg.QUESTION,
			fn: function(d) {
				if (d == "yes") {
					a.store.proxy.extraParams.filterModel = undefined;
					a.store.proxy.extraParams.offset = undefined;
					addExceptionListenerOnProxy(a.proxy, "shoporderreleaselist");
					a.getProxy().extraParams.resourceID = "ShopOrderController.deleteShopOrder";
					a.destroy({
						scope: this,
						success: function(f, e) {
							Ext.CustomMessageBox.msg("shoporderreleaselist", bundle.getMsg("socontrol.ok"), bundle.getMsg("socontrol.successfullyDeleted"));
							b.refreshGrid()
						}
					})
				}
			}
		})
	},
	onPartNumberSelection: function(c, b) {
		if (b.length < 1) {
			return
		}
		var a = b[0];
		this.reloadRevisionCombo(a.get("id"))
	},
	reloadRevisionCombo: function(c, a) {
		var b = this.getShopOrderForm().down("revisioneditor");
		if (c > 0) {
			b.getStore().getProxy().extraParams.partId = c;
			b.getStore().load({
				scope: this,
				callback: function() {
					if (a != null && a != "") {
						if (!b.getStore().findRecord("revision", a)) {
							b.getStore().insert(0, {
								revision: a
							})
						}
						b.setValue(a)
					}
					b.allowBlank = b.getStore().getCount() == 0;
					this.getShopOrderForm().getForm().isValid()
				}
			});
			if (a) {
				b.setValue(a)
			}
		} else {
			b.getStore().removeAll();
			b.allowBlank = true
		}
		this.getShopOrderForm().getForm().isValid()
	},
	onSaveShopOrderForm: function(c) {
		var e = this.getShopOrderForm().getForm();
		var b = e.getRecord();
		var a = Ext.getCmp("shoporderformwindow");
		var d = a.isEdit;
		if (e.isValid()) {
			e.updateRecord(b);
			a.getEl().mask("Loading...");
			if (d) {
				b.getProxy().extraParams.resourceID = "ShopOrderController.editShopOrder"
			} else {
				b.getProxy().extraParams.resourceID = "ShopOrderController.addShopOrder"
			}
			b.save({
				scope: this,
				success: function(g, f) {
					a.getEl().unmask();
					Ext.getCmp("shoporderformwindow").destroy();
					Ext.CustomMessageBox.msg("shoporderreleaselist", bundle.getMsg("socontrol.ok"), bundle.getMsg("socontrol.successfullySaveSO"));
					this.refreshGrid()
				},
				failure: function() {
					a.getEl().unmask();
					b.reject()
				}
			})
		}
	},
	onResetShopOrderForm: function(b) {
		var a = this.getShopOrderForm().getRecord();
		this.getShopOrderForm().loadRecord(a);
		pnCombo = this.getShopOrderForm().down("partnumbereditor");
		pnCombo.setValue(a.getPartNumber().get("partNumber"));
		this.reloadRevisionCombo(a.get("partId"), a.get("revision"));
		this.getShopOrderForm().getForm().isValid()
	},
	onCancelShopOrderForm: function(b) {
		var c = this.getShopOrderForm().getForm();
		var a = c.getRecord();
		a.reject();
		this.getShopOrderForm().up("shoporderformwindow").close()
	},
	findSNByTypeOperationSequence: function(b) {
		var a = Ext.getCmp("operationSequence").store;
		a.filter("opseq", b);
		a.clearFilter(true)
	},
	findSNByTypeLocationProcess: function(b) {
		var a = Ext.getCmp("locationProcess").store;
		a.filter("name", b);
		a.clearFilter(true)
	},
	onOkSelectMappingType: function() {
		var c = "";
		var b = 0;
		if (Ext.getCmp("process").getValue()) {
			c = bundle.getMsg("socontrol.process");
			b = 1
		} else {
			if (Ext.getCmp("location").getValue()) {
				c = bundle.getMsg("socontrol.location");
				b = 2
			}
		}
		if (b != 0) {
			var a = Ext.getCmp("selectmappingtypewindow").soRecord;
			a.set("mappingTypeKey", b);
			a.set("mappingTypeLabel", c);
			Ext.getCmp("selectmappingtypewindow").close();
			this.openShopOrderMapping(a)
		}
	},
	openShopOrderMapping: function(c) {
		var e = this;
		c.set("partNumberField", c.getPartNumber().get("partNumber"));
		this.pushScreen("shopordermapping", {
			viewOnly: !checkPermission("shopOrder.shopOrderRelease.mapShopOrder")
		});
		Ext.getCmp("shopOrderInformationPanel").getForm().loadRecord(c);
		Ext.getCmp("mappingTypeLabel").setValue(c.get("mappingTypeLabel"));
		var d = Ext.getCmp("mappedOperationSequence");
		d.getEl().mask("Loading...");
		var b = Ext.create("SO.store.OperationSequenceStore");
		b.loadData(operationSequenceGlobal);
		Ext.getCmp("operationSequence").reconfigure(b);
		var a = "";
		if (c.get("mappingTypeKey") == 1) {
			a = e.getStore("ProcessStore");
			a.proxy.extraParams.shopOrderId = c.getId();
			a.proxy.extraParams.resourceID = "MappingController.getProcessForMappingType"
		} else {
			if (c.get("mappingTypeKey") == 2) {
				a = e.getStore("LocationStore");
				a.proxy.extraParams.shopOrderId = c.getId();
				a.proxy.extraParams.resourceID = "MappingController.locationForMappingType"
			}
		}
		addExceptionListenerOnProxy(a.getProxy(), "shopordermapping");
		a.load({
			callback: function(g, f, h) {
				if (h) {
					Ext.Ajax.request({
						scope: this,
						url: window.windowSOContext.ajaxURL,
						format: "json",
						params: {
							resourceID: "MappingController.findMappings",
							mapKey: c.get("mappingId"),
							soKey: c.getId()
						},
						success: function(j) {
							var k = Ext.decode(j.responseText);
							var i = Ext.create("SO.store.MappedStore");
							i.loadData(k.data);
							i.commitChanges();
							d.reconfigure(i);
							d.getEl().unmask()
						},
						failure: function(i) {
							d.getEl().unmask();
							failureHandler(i, "shopordermapping")
						}
					})
				} else {
					d.getEl().unmask()
				}
			}
		});
		Ext.getCmp("locationProcess").reconfigure(a);
		Ext.Ajax.request({
			url: window.windowSOContext.ajaxURL,
			format: "json",
			params: {
				resourceID: "MappingController.hasOtherMappings",
				opSeqListKey: c.get("opSeqListKey"),
				mapTypeKey: c.get("mapTypeKey")
			},
			success: function(f) {
				var g = Ext.decode(f.responseText);
				Ext.getCmp("otherMappingsAvailable").setDisabled(!g.data)
			},
			failure: function(f) {
				failureHandler(f, "shopordermapping")
			}
		})
	},
	onShopOrderMapClick: function(b) {
		var d = this;
		operationSequenceGlobal = "";
		mappinsGlobal = "";
		if (b.get("shopOrderStatus") == "R") {
			Ext.CustomMessageBox.msg("shoporderreleaselist", bundle.getMsg("socontrol.message.information"), bundle.getMsg("error.progress.socontrol.shopOrderReleasedOrClosed"))
		} else {
			var a = Ext.getCmp("xmain"),
				c;
			a.getEl().mask("Loading ...");
			Ext.Ajax.request({
				url: window.windowSOContext.ajaxURL,
				format: "json",
				params: {
					resourceID: "MappingController.checkPartRoute",
					shopOrderNumber: b.get("shopOrderNumber"),
					shopOrderId: b.get("id")
				},
				success: function(e) {
					var f = Ext.decode(e.responseText);
					c = f.partHasRoute;
					operationSequenceGlobal = f.opSeqList;
					a.getEl().unmask();
					if (!c) {
						Ext.CustomMessageBox.msg("shoporderreleaselist", bundle.getMsg("socontrol.message.error"), bundle.getMsg("error.progress.socontrol.partHasNoRoute"))
					} else {
						if (b.get("mapTypeKey") == 0) {
							Ext.widget("selectmappingtypewindow", {
								soRecord: b
							}).show()
						} else {
							if (b.get("mapTypeKey") != 0) {
								b.set("mappingTypeKey", b.get("mapTypeKey"));
								if (b.get("mappingTypeKey") == 1) {
									b.set("mappingTypeLabel", "Process")
								} else {
									if (b.get("mappingTypeKey") == 2) {
										b.set("mappingTypeLabel", "Location")
									}
								}
								d.openShopOrderMapping(b)
							}
						}
					}
				},
				failure: function(e) {
					a.getEl().unmask();
					failureHandler(e, "shoporderreleaselist")
				}
			})
		}
	},
	addMappingInMappedGrid: function(e, d) {
		var c = Ext.create("SO.model.MappingInformationModel");
		var b = Ext.getCmp("shopOrderInformationPanel").getForm().getRecord();
		if (b.get("mappingTypeKey") == 1) {
			c.set("locProc", d.data.name)
		} else {
			if (b.get("mappingTypeKey") == 2) {
				c.set("locProc", d.data.locationKey)
			}
		}
		c.set("mapTypeKey", b.get("mappingTypeKey"));
		c.set("mapOpSeq", e.data.opseq);
		c.set("invalid", false);
		var a = Ext.getCmp("mappedOperationSequence").store;
		if (!a.findRecord("locProc", c.get("locProc"))) {
			a.add(c)
		}
	},
	onAddMapClick: function() {
		var a = this;
		var c = Ext.getCmp("operationSequence").getSelectionModel().getSelection()[0];
		var b = Ext.getCmp("locationProcess").getSelectionModel().getSelection()[0];
		if (typeof(c) == "undefined") {
			Ext.CustomMessageBox.msg("shopordermapping", bundle.getMsg("socontrol.message.error"), bundle.getMsg("socontrol.release.mapping.mustSelectOpSeq"));
			return
		} else {
			if (typeof(b) == "undefined") {
				Ext.CustomMessageBox.msg("shopordermapping", bundle.getMsg("socontrol.message.error"), bundle.getMsg("socontrol.release.mapping.mustSelectLocProc"));
				return
			}
		}
		a.addMappingInMappedGrid(c, b)
	},
	onAutomaticMapClick: function() {
		var a = this;
		if (a.hasAutomaticMapping()) {
			if (Ext.getCmp("mappedOperationSequence").store.count() != 0) {
				Ext.Msg.show({
					title: bundle.getMsg("socontrol.message.information"),
					msg: bundle.getMsg("socontrol.release.mapping.confirmAutomaticMapping"),
					buttons: Ext.Msg.YESNO,
					icon: Ext.Msg.INFO,
					fn: function(b) {
						if (b == "yes") {
							a.doAutomaticMapping()
						}
					}
				})
			} else {
				a.doAutomaticMapping()
			}
		} else {
			Ext.CustomMessageBox.msg("shopordermapping", bundle.getMsg("socontrol.message.information"), bundle.getMsg("socontrol.release.mapping.noAvailableMapping"))
		}
	},
	hasAutomaticMapping: function() {
		var a = false;
		Ext.getCmp("operationSequence").store.getRange().forEach(function(b) {
			Ext.getCmp("locationProcess").store.getRange().forEach(function(c) {
				if (b.data.opseq == c.data.name) {
					a = true
				}
			})
		});
		return a
	},
	doAutomaticMapping: function() {
		var a = this;
		Ext.getCmp("mappedOperationSequence").store.removeAll();
		Ext.getCmp("operationSequence").store.getRange().forEach(function(b) {
			Ext.getCmp("locationProcess").store.getRange().forEach(function(c) {
				if (b.data.opseq == c.data.name) {
					a.addMappingInMappedGrid(b, c)
				}
			})
		})
	},
	onOtherMappingsAvailableClick: function() {
		var a = Ext.getCmp("shopOrderInformationPanel").getForm().getRecord(),
			c = Ext.widget("othermappingsavailablewindow"),
			b = Ext.getCmp("othermappinggrid");
		c.show();
		b.getEl().mask("Loading ...");
		Ext.Ajax.request({
			url: window.windowSOContext.ajaxURL,
			params: {
				resourceID: "MappingController.getOldMappings",
				shopOrderId: a.getId(),
				mapTypeKey: a.get("mapTypeKey"),
				opSeqListKey: a.get("opSeqListKey"),
				onlyCheck: "false"
			},
			success: function(d) {
				var f = Ext.decode(d.responseText);
				var e = Ext.create("SO.store.MappedStore");
				e.loadData(f.data);
				e.sort("opMapKey", "ASC");
				b.reconfigure(e);
				b.getEl().unmask()
			},
			failure: function(d) {
				b.getEl().unmask();
				failureHandler(d, "othermappingsavailablewindow")
			}
		})
	},
	selectOldMapping: function(a, b, k, f, g, h) {
		if (f != -1) {
			var c = Ext.getCmp("shopOrderInformationPanel").getForm().getRecord(),
				i = Ext.getCmp("mappingsAvailable"),
				d = Ext.getCmp("othermappinggrid"),
				j = d.getSelectionModel().getSelection()[0];
			i.getEl().mask("Loading ...");
			Ext.Ajax.request({
				scope: this,
				url: window.windowSOContext.ajaxURL,
				format: "json",
				params: {
					resourceID: "MappingController.findMappings",
					mapKey: j.get("opMapKey"),
					soKey: c.getId()
				},
				success: function(l) {
					var m = Ext.decode(l.responseText),
						e = Ext.create("SO.store.MappedStore");
					e.loadData(m.data);
					i.reconfigure(e);
					i.getEl().unmask()
				},
				failure: function() {
					i.getEl().unmask();
					failureHandler(response, "othermappingsavailablewindow")
				}
			})
		}
	},
	onOkOtherMappingsAvailable: function() {
		var a = Ext.getCmp("mappedOperationSequence").store;
		a.removeAll();
		a.loadData(Ext.getCmp("mappingsAvailable").store.getRange());
		Ext.getCmp("othermappingsavailablewindow").close()
	},
	onCancelOtherMappingsAvailable: function() {
		Ext.getCmp("othermappingsavailablewindow").close()
	},
	onCancelShopOrderMapping: function() {
		this.pushScreen("shoporderreleaselist")
	},
	checkIsValid: function() {
		var a = true;
		Ext.getCmp("mappedOperationSequence").store.getRange().forEach(function(b) {
			if (b.data.invalid) {
				a = false
			}
		});
		return a
	},
	onSaveShopOrderMapping: function() {
		var c = this;
		if (Ext.getCmp("mappedOperationSequence").store.count() != 0) {
			if (c.checkIsValid()) {
				var a = Ext.getCmp("shopOrderInformationPanel").getForm().getRecord(),
					b = Ext.getCmp("mappedOperationSequence").store;
				b.commitChanges();
				b.getRange().forEach(function(d) {
					d.setDirty();
					d.phantom = true
				});
				addExceptionListenerOnProxy(b.getProxy(), "shopordermapping");
				c.addListenerSuccessToStore(b, "shopordermapping");
				b.proxy.extraParams.shopOrderKey = a.getId();
				b.proxy.extraParams.mappingTypeKey = a.get("mappingTypeKey");
				b.proxy.extraParams.mappingId = 0;
				b.sync()
			} else {
				Ext.CustomMessageBox.msg("shopordermapping", bundle.getMsg("socontrol.message.information"), bundle.getMsg("socontrol.release.mapping.saveInvalidMapping"))
			}
		} else {
			Ext.CustomMessageBox.msg("shopordermapping", bundle.getMsg("socontrol.message.information"), bundle.getMsg("socontrol.release.mapping.saveEmptyMapping"))
		}
	},
	onRemoveShopOrderMapping: function() {
		var b = Ext.getCmp("mappedOperationSequence");
		var c = Ext.getCmp("mappedOperationSequence").getSelectionModel().getSelection()[0];
		var a = b.store;
		a.remove(c)
	},
	onCancelMappingType: function() {
		Ext.getCmp("selectmappingtypewindow").close()
	},
	pushScreen: function(a, b) {
		this.application.controllers.get("ShopOrderController").pushScreen(a, b)
	}
});
Ext.define("SO.model.SalesOrderVOModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "key",
		type: "int"
	}, {
		name: "salesOrder",
		type: "string"
	}, {
		name: "carrier",
		type: "string"
	}, {
		name: "totalQuantity",
		type: "int"
	}, {
		name: "totalUnitQty",
		type: "int"
	}, {
		name: "allUnitsAssigned",
		type: "boolean"
	}, {
		name: "address1",
		type: "string"
	}, {
		name: "address2",
		type: "string"
	}, {
		name: "address3",
		type: "string"
	}, {
		name: "customerName",
		type: "string"
	}, {
		name: "country",
		type: "string"
	}, {
		name: "postCode",
		type: "string"
	}, {
		name: "deliveryDate",
		type: "string"
	}, {
		name: "customerNumber",
		type: "string"
	}, {
		name: "customerPoNumber",
		type: "string"
	}, {
		name: "shiptoCustPoNumber",
		type: "string"
	}, {
		name: "state",
		type: "string"
	}, {
		name: "addlPoNumber",
		type: "string"
	}, {
		name: "orderedDate",
		type: "string"
	}, {
		name: "nortelJobSpecLot",
		type: "string"
	}, {
		name: "programManagerName",
		type: "string"
	}, {
		name: "orderLineKeysList",
		type: "string"
	}, {
		name: "assignedPercentage",
		type: "string"
	}, {
		name: "extractType",
		type: "string"
	}],
	hasMany: [{
		model: "SO.model.SalesOrderLineModel",
		name: "orderLineList"
	}],
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "SalesOrderController.getSalesOrderToUpdate"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			messageProperty: "message",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	}
});
Ext.define("SO.store.SalesOrderStore", {
	extend: Common.store.PaggingStore,
	model: "SO.model.SalesOrderVOModel",
	pageSize: 50,
	remoteSort: false,
	remoteFilter: false,
	autoLoad: false
});
var canExceedsQty = false;
var container = new Array();
Ext.define("SO.controller.SalesOrderController", {
	extend: Ext.app.Controller,
	stores: ["SalesOrderStore", "SerialNumberStore"],
	views: ["SalesOrder.SalesOrderList", "SalesOrder.SalesOrderFilter", "SalesOrder.AssignSerialNumberWindow", "util.AddMultipleSerialNumbersWindow", "SalesOrder.SalesOrderInformation", "SalesOrder.PushSalesOrderWindow", "SalesOrder.RequestSalesOrderFormWindow"],
	init: function() {
		Ext.Ajax.request({
			type: "ajax",
			format: "json",
			url: window.windowSOContext.ajaxURL,
			params: {
				resourceID: "SalesOrderController.checkCanExceedQtyAtt"
			},
			success: function(a) {
				var b = Ext.decode(a.responseText);
				canExceedsQty = b.canExceedsQty
			}
		});
		this.control({
			"salesorderlist button[action=onOpenAddPanelFromList]": {
				click: this.onOpenAssignPanelFromList
			},
			"salesorderlist button[action=onReloadSalesOrder]": {
				click: this.onReloadSalesOrder
			},
			"salesorderlist button[action=onPrintExportSalesOrderList]": {
				click: this.onPrintExportSalesOrderList
			},
			"#assignserialnumberwindow button[action=onSave]": {
				click: this.onSaveAdd
			},
			"#assignserialnumberwindow button[action=onCancel]": {
				click: this.onAssignCancel
			},
			"#assignserialnumberwindow button[action=reset]": {
				click: this.resetAssignFromSalesOrderScreen
			},
			"#assignserialnumberwindow button[action=remove]": {
				click: this.removeAssignFromSalesOrderScreen
			},
			"#salesorderinformation button[action=onOpenAddPanelFromInfo]": {
				click: this.onOpenAssignPanelFromInfo
			},
			"#salesorderinformation button[action=onDeleteSerialsFromOrderLine]": {
				click: this.onDeleteSerialsFromOrderLine
			},
			"assignserialnumberwindow customtriggerfield[id=findSNToSelect]": {
				triggerclick: function() {
					this.onOpenSerialWindow()
				},
				keypress: function(b, a) {
					if (a.getKey() == Ext.EventObject.ENTER && b.value != null && b.value != "") {
						this.findSNAddToSelect(b.getValue())
					}
				}
			},
			"assignserialnumberwindow textfield[id=findCNTRToSelect]": {
				keypress: function(b, a) {
					if (a.getKey() == Ext.EventObject.ENTER && b.value != null && b.value != "") {
						this.findCNTRAddToSelect(b.getValue())
					}
				}
			},
			"assignserialnumberwindow textfield[id=findCNTRToRemove]": {
				keypress: function(b, a) {
					if (a.getKey() == Ext.EventObject.ENTER && b.value != null && b.value != "") {
						this.onRemoveContainerButton(b.getValue())
					}
				}
			},
			"assignserialnumberwindow customtriggerfield[id=findSNToRemove]": {
				triggerclick: function() {
					this.onOpenSerialToRemoveWindow()
				},
				keypress: function(b, a) {
					if (a.getKey() == Ext.EventObject.ENTER && b.value != null && b.value != "") {
						this.onRemoveSerialButton()
					}
				}
			},
			"assignserialnumberwindow combobox[id=orderLineCombo]": {
				select: function(c, a, b) {
					this.selectOrderLineOnManageSerials(a[0])
				}
			},
			"assignserialnumberwindow grid[id=selected]": {
				itemdblclick: function(g, f, c, a, d, b) {
					this.itemDoubleClickToRemoved(g, f, c, a, d, b)
				}
			},
			"assignserialnumberwindow grid[id=removed]": {
				itemdblclick: function(g, f, c, a, d, b) {
					this.itemDoubleClickToSelected(g, f, c, a, d, b)
				}
			},
			"addmultipleserialwindow #serialNumberToAssign": {
				select: this.onChangeSerialNumber
			},
			"addmultipleserialwindow button[action=onAddSerial]": {
				click: this.onAddSerialWindow
			},
			"addmultipleserialwindow button[action=onRemoveSerial]": {
				click: this.onRemoveSerial
			},
			"addmultipleserialwindow customtriggerfield[id=soNumberonAddSerial]": {
				triggerclick: function(a) {
					this.onLoadSerialGridByShopOrder(a.getValue())
				},
				keypress: function(b, a) {
					if (a.getKey() == Ext.EventObject.ENTER) {
						this.onLoadSerialGridByShopOrder(b.getValue())
					}
				}
			},
			"addmultipleserialwindow customtriggerfield[id=soNumberonRemoveSerial]": {
				triggerclick: function(a) {
					this.onFilterSerialGridByShopOrder(a.getValue())
				},
				keypress: function(b, a) {
					if (a.getKey() == Ext.EventObject.ENTER) {
						this.onFilterSerialGridByShopOrder(b.getValue())
					}
				}
			},
			"addmultipleserialwindow button[id=selectAllonAddSerial]": {
				click: this.onSelectAllSerialToAdd
			},
			"addmultipleserialwindow button[id=selectAllonRemoveSerial]": {
				click: this.onSelectAllSerialToRemove
			},
			"addmultipleserialwindow grid[id=serialGrid]": {
				itemdblclick: function(g, f, c, a, d, b) {
					if (a != -1) {
						this.addSerialFromGrid(Ext.getCmp("serialList"), f)
					}
				}
			},
			"addmultipleserialwindow button[id=reset]": {
				click: function() {
					Ext.getCmp("serialList").setValue("")
				}
			},
			"addmultipleserialwindow textareafield": {
				keypress: function(b, a) {
					if (a.getKey() == a.ENTER) {
						this.onEnterList(b.getValue(), a)
					}
				}
			},
			"pushsalesorderwindow button[action=salesOrderOracleFilter]": {
				click: this.onSalesOrderFilterFromOracle
			},
			"pushsalesorderwindow button[action=clearResearch]": {
				click: this.onClearResearch
			},
			"salesorderlist button[action=onrequestSalesOrder]": {
				click: this.onRequestSalesOrderToolbar
			},
			"requestsalesorderformwindow button[action=cancel]": {
				click: this.onCancelRequestSalesOrder
			},
			"requestsalesorderformwindow button[action=requestSalesOrder]": {
				click: this.onRequestSalesOrder
			},
			"requestsalesorderformwindow #comboSalesOrderRequest": {
				change: this.onSelectComboSalesOrderRequest
			}
		});
		this.application.on({
			onSalesOrderInfo: this.onSalesOrderInfo,
			scope: this
		})
	},
	onSelectComboSalesOrderRequest: function(d, c, a, b) {
		Ext.getCmp(c).setVisible(true);
		Ext.getCmp(a).setVisible(false)
	},
	onRequestSalesOrder: function() {
		var b = Ext.getCmp("requestsalesorderformwindow"),
			c = b.down("form").getForm(),
			a = c.getRecord();
		c.updateRecord(a);
		if (c.isValid()) {
			b.getEl().mask("Loading...");
			Ext.Ajax.request({
				type: "ajax",
				format: "json",
				url: window.windowSOContext.ajaxURL,
				params: {
					resourceID: "SalesOrderController.onRequestSalesOrder",
					salesOrder: a.data.salesOrder,
					partNumber: a.data.partNumber
				},
				success: function(f, e) {
					b.close();
					var d = Ext.decode(f.responseText);
					Ext.CustomMessageBox.msg("salesorderlist", bundle.getMsg("socontrol.message.successful"), Ext.String.format(bundle.getMsg("salesOrder.requestSalesOrderSuccess"), d.taskId))
				},
				failure: function(e, d) {
					b.getEl().unmask();
					failureHandler(e, "requestsalesorderformwindow")
				}
			})
		}
	},
	onRequestSalesOrderToolbar: function() {
		var a = Ext.widget("requestsalesorderformwindow");
		a.show();
		Ext.define("SO.model.SalesOrderRequest", {
			extend: Ext.data.Model,
			fields: [{
				name: "salesOrder",
				type: "string"
			}, {
				name: "partNumber",
				type: "string"
			}]
		});
		var b = Ext.create("SO.model.SalesOrderRequest"),
			c = a.down("form").getForm();
		c.loadRecord(b);
		c.isValid()
	},
	onCancelRequestSalesOrder: function(a) {
		a.up("window").close()
	},
	resetAssignFromSalesOrderScreen: function() {
		var g = Ext.getCmp("assignserialnumberform").getForm();
		if (g.getRecord() != null && g.getRecord() != undefined) {
			var b = g.getRecord(),
				a = Ext.getCmp("assignserialnumberwindow"),
				f = Ext.getCmp("selected").store,
				h = Ext.getCmp("removed").store,
				e = Ext.getCmp("selected"),
				d = Ext.getCmp("removed");
			f.loadData(a.originalData);
			h.removeAll();
			if (a.calledFrom == "salesorderinformation") {
				var c = e.getStore();
				c.loadPage(1);
				this.refreshSerialProgressBar("summarySerialProgressBar", b.data.quantity, b.data.unitsQty)
			} else {
				if (a.calledFrom == "salesorderlist") {
					g.reset();
					Ext.getCmp("summarySerialProgressBar").updateProgress(0, " ", true);
					Ext.getCmp("findSNToSelect").setDisabled(true);
					Ext.getCmp("findSNToRemove").setDisabled(true);
					var c = Ext.create("SO.store.SerialNumberStore");
					e.reconfigure(c);
					e.setDisabled(false);
					d.setDisabled(false)
				}
			}
		}
	},
	removeAssignFromSalesOrderScreen: function() {
		var c = Ext.getCmp("selected");
		var d = c.getSelectionModel().getSelection();
		var a = d[0];
		var b = Ext.getCmp("selected").store;
		b.remove(a);
		this.refreshSerialProgressBar("summarySerialProgressBar", Ext.getCmp("quantityField").getValue(), b.data.length)
	},
	findSNAddToSelect: function(b) {
		var a = this;
		var d = Ext.getCmp("selected").store;
		quantity = parseInt(Ext.getCmp("quantityField").getValue()), unisQty = parseInt(Ext.getCmp("unitsQtyField").getValue()), selectQty = this.countSerialsProgressBar();
		if ((1 + selectQty <= quantity) || canExceedsQty) {
			var c = Ext.create("SO.model.SerialNumberModel");
			c.set("serialNumber", b.toUpperCase());
			c.set("quantity", 1);
			if (!d.getById(b.toUpperCase())) {
				d.add(c);
				Ext.getCmp("removed").setDisabled(false);
				Ext.getCmp("unitsQtyField").setValue(unisQty + 1);
				this.countSerialsProgressBar()
			} else {
				Ext.CustomMessageBox.msg("assignserialnumberwindow", bundle.getMsg("socontrol.message.information"), bundle.getMsg("socontrol.serialNumberAlreadyinList"))
			}
		} else {
			Ext.CustomMessageBox.msg("assignserialnumberwindow", bundle.getMsg("socontrol.message.error"), Ext.String.format(bundle.getMsg("error.salesOrder.assignSnToSalesOrder.qty")))
		}
		Ext.getCmp("findSNToSelect").setValue("")
	},
	findCNTRAddToSelect: function(c) {
		var b = this,
			d = Ext.getCmp("selected").getStore(),
			a = Ext.getCmp("findCNTRToSelect");
		if (d.getById(c.toUpperCase())) {
			Ext.CustomMessageBox.msg("assignserialnumberwindow", bundle.getMsg("socontrol.message.information"), bundle.getMsg("socontrol.serialNumberAlreadyinList"));
			a.setValue("");
			return
		}
		a.getEl().mask("Searching...");
		Ext.Ajax.request({
			type: "ajax",
			url: window.windowSOContext.ajaxURL,
			method: "GET",
			async: true,
			format: "json",
			scope: this,
			params: {
				resourceID: "SalesOrderController.getSerialsFromContainer",
				container: c.toUpperCase()
			},
			success: function(f) {
				var e = Ext.decode(f.responseText);
				if (e.qty != undefined && e.qty > 0) {
					var h = parseInt(Ext.getCmp("quantityField").getValue()),
						g = parseInt(Ext.getCmp("unitsQtyField").getValue());
					selectQty = this.countSerialsProgressBar();
					if ((e.qty + selectQty <= h) || canExceedsQty) {
						a.setValue("");
						var i = Ext.create("SO.model.SerialNumberModel");
						i.set("id", e.id);
						i.set("serialNumber", e.container.toUpperCase());
						i.set("arrayContainerKey", e.arrayContainerKey);
						i.set("quantity", e.qty);
						i.set("containerKey", e.container_serial_key);
						i.set("isContainer", true);
						if (e.order_line_key == 0) {
							d.add(i);
							Ext.getCmp("removed").setDisabled(false);
							Ext.getCmp("unitsQtyField").setValue(g + e.qty);
							this.countSerialsProgressBar()
						} else {
							Ext.CustomMessageBox.msg("assignserialnumberwindow", bundle.getMsg("socontrol.message.error"), bundle.getMsg("error.salesOrder.containerIsInOtherLine"))
						}
					} else {
						Ext.CustomMessageBox.msg("assignserialnumberwindow", bundle.getMsg("socontrol.message.error"), Ext.String.format(bundle.getMsg("error.salesOrder.assignSnToSalesOrder.qty")))
					}
				} else {
					Ext.CustomMessageBox.msg("assignserialnumberwindow", bundle.getMsg("socontrol.message.error"), bundle.getMsg("error.salesOrder.containerNotExist"))
				}
				a.setValue("");
				a.getEl().unmask()
			},
			failure: function(e) {
				a.getEl().unmask();
				failureHandler(e, "assignserialnumberwindow")
			}
		})
	},
	onOpenAssignPanelFromList: function() {
		var c = Ext.getCmp("salesorderlist");
		var e = c.getSelectionModel().getSelection();
		var b = e[0];
		if (b) {
			var a = Ext.create("SO.view.SalesOrder.AssignSerialNumberWindow", {
				visibleCombo: true,
				calledFrom: "salesorderlist"
			});
			var d = Ext.getCmp("selected"),
				g = Ext.create("SO.store.SerialNumberStore");
			d.reconfigure(g);
			a.show();
			var f = Ext.getCmp("orderLineCombo");
			f.getStore().proxy.extraParams.salesOrderKey = b.data.key;
			f.getStore().load()
		}
	},
	onReloadSalesOrder: function() {
		Ext.create("SO.view.SalesOrder.PushSalesOrderWindow").show()
	},
	onOpenAssignPanelFromInfo: function(c, f, b) {
		var d = this,
			a = Ext.getCmp(c.id).up().up().record,
			g = Ext.getCmp("seriallist" + a.data.key).getStore().data.items;
		if (a) {
			Ext.Ajax.request({
				type: "ajax",
				format: "json",
				url: window.windowSOContext.ajaxURL,
				params: {
					resourceID: "SalesOrderController.getSerialsByOrderLineKeyNoLimit",
					key: a.data.key
				},
				success: function(j, i) {
					var e = Ext.decode(j.responseText);
					var l = Ext.create("SO.ux.PagingStore", {
						model: "SO.model.SerialNumberModel",
						proxy: {
							type: "memory",
							reader: {
								type: "array"
							}
						},
						data: []
					});
					l.loadData(e.data);
					var h = Ext.create("SO.view.SalesOrder.AssignSerialNumberWindow", {
						visibleCombo: false,
						calledFrom: "salesorderinformation",
						originalData: e.data
					});
					Ext.getCmp("assignedFieldSet").setDisabled(false);
					a.serialNumberList().sort("serialNumber", "ASC");
					d.populateAssignSerialPanel(a, l);
					var k = Ext.getCmp("orderLineCombo");
					k.setValue(a.get("orderLine"));
					h.show()
				}
			})
		}
	},
	populateAssignSerialPanel: function(b, c) {
		var e = Ext.getCmp("selected");
		e.reconfigure(c);
		var a = e.down("pagingtoolbar");
		a.bindStore(c);
		a.doRefresh();
		Ext.getCmp("findSNToSelect").setDisabled(canExceedsQty == false && b.data.allUnitsAssigned == true);
		Ext.getCmp("removed").setDisabled(false);
		Ext.getCmp("findSNToRemove").setDisabled(false);
		var d = Ext.getCmp("removed");
		d.reconfigure(Ext.create("SO.store.SerialNumberStore"));
		var f = Ext.getCmp("assignserialnumberform").getForm();
		addExceptionListenerOnProxy(b.proxy, "salesrderinformation");
		f.loadRecord(b);
		this.refreshSerialProgressBar("summarySerialProgressBar", b.data.quantity, b.data.unitsQty)
	},
	onSaveAdd: function() {
		var d = Ext.getCmp("assignserialnumberform").getForm();
		if (d.getRecord() != null && d.getRecord() != undefined) {
			var c = this,
				a = d.getRecord(),
				e = a.data.quantity,
				b = Ext.getCmp("selected").getStore(),
				f = Ext.getCmp("removed").getStore();
			if (b.getCount() > 0 || f.getCount() > 0) {
				if (b.getCount() > e) {
					Ext.Msg.show({
						title: bundle.getMsg("socontrol.message.information"),
						msg: bundle.getMsg("error.salesOrder.assignSnToSalesOrder.qty"),
						buttons: Ext.Msg.OK,
						icon: Ext.Msg.INFO,
						fn: function(g) {
							if (g == "ok") {
								c.efetiveSave(b, f, a)
							}
						}
					})
				} else {
					c.efetiveSave(b, f, a)
				}
			}
		}
	},
	efetiveSave: function(d, g, b) {
		var a = Ext.getCmp("assignserialnumberwindow"),
			c = new Array(),
			h = new Array(),
			f = Ext.getCmp("seriallist" + b.data.key),
			e = this;
		a.getEl().mask("Loading...");
		d.getNewRecords().forEach(function(i) {
			if (!g.getById(i.data.serialNumber)) {
				c.push(i.data.serialNumber)
			}
		});
		g.getRange().forEach(function(i) {
			if (typeof i.data.id != "undefined" && !d.getById(i.data.serialNumber)) {
				h.push(i.data.id)
			}
		});
		Ext.Ajax.request({
			type: "ajax",
			format: "json",
			url: window.windowSOContext.ajaxURL,
			params: {
				resourceID: "SalesOrderController.saveSerialNumbersForOrderLine",
				lineOrderKey: b.data.key,
				newAssign: Ext.encode(c),
				removedSerials: Ext.encode(h)
			},
			success: function(l, k) {
				var i = Ext.decode(l.responseText);
				if (i.errorList != undefined && i.errorList.length != 0) {
					var j = Ext.create("SO.Custom.ErrorListWindow", {
						title: bundle.getMsg("socontrol.message.errorSummary"),
						summaryLabelText: Ext.String.format(bundle.getMsg("salesOrder.assignSNResult")),
						gridHeaderValue: bundle.getMsg("socontrol.serialNumber"),
						showErrorMsg: true
					});
					j.down("grid").getStore().loadData(i.errorList);
					j.show()
				} else {
					Ext.CustomMessageBox.msg(a.calledFrom, bundle.getMsg("socontrol.message.successful"), bundle.getMsg("socontrol.serialnumber.successfullyAssignedSaved"))
				}
				if (a.calledFrom == "salesorderinformation") {
					e.refreshSalesOrderInfo(i.serialsAssigned, b, f)
				} else {
					e.refreshGrid()
				}
				a.getEl().unmask();
				a.close()
			},
			failure: function(j, i) {
				a.getEl().unmask();
				failureHandler(j, "assignserialnumberwindow")
			}
		})
	},
	refreshSalesOrderInfo: function(h, a, g) {
		var b = a.get("unitsQty");
		a.set("assignedPercentage", h + "/" + a.data.quantity);
		a.set("unitsQty", h);
		var c = Ext.getCmp("salesOrderStandardPanel").getForm().getRecord(),
			e = c.data.totalUnitQty - b + a.get("unitsQty");
		c.set("totalUnitQty", e);
		this.refreshSerialProgressBar("slInfoSerialProgressBar", c.data.totalQuantity, e);
		this.refreshSerialProgressBar("olSerialProgressBar" + a.data.key, a.data.quantity, a.data.unitsQty);
		var d = Ext.getCmp("StandardPanel" + a.data.key).getForm();
		d.loadRecord(a);
		var f = g.getStore();
		f.proxy.extraParams.resourceID = "SalesOrderController.getSerialsByOrderLineKey";
		f.proxy.extraParams.key = a.data.key;
		g.reconfigure(f.loadPage(1, {
			callback: function() {
				if (g.getStore().data.length > 0) {
					g.setVisible(true)
				} else {
					g.setVisible(false)
				}
			}
		}))
	},
	onDeleteSerialsFromOrderLine: function(c, g, b) {
		var a = Ext.getCmp(c.id).up().up().record,
			f = Ext.getCmp("seriallist" + a.data.key),
			d = f.getSelectionModel().getSelection(),
			h = new Array();
		d.forEach(function(e) {
			h.push(e.data.id)
		});
		Ext.Msg.show({
			scope: this,
			title: bundle.getMsg("socontrol.confirm"),
			msg: Ext.String.format(bundle.getMsg("salesOrder.removeSerialNumber"), Ext.getCmp("salesOrder").getValue(), a.get("orderLine")),
			buttons: Ext.Msg.YESNO,
			icon: Ext.Msg.QUESTION,
			fn: function(e) {
				if (e == "yes") {
					this.efetiveDelete(h, a, f)
				}
			}
		})
	},
	efetiveDelete: function(e, b, d) {
		var c = this,
			a = Ext.getCmp("salesorderinformation");
		a.getEl().mask("Loading...");
		Ext.Ajax.request({
			type: "ajax",
			format: "json",
			url: window.windowSOContext.ajaxURL,
			params: {
				resourceID: "SalesOrderController.saveSerialNumbersForOrderLine",
				lineOrderKey: b.get("key"),
				removedSerials: Ext.encode(e),
				newAssign: Ext.encode(new Array())
			},
			success: function(h, g) {
				var f = Ext.decode(h.responseText);
				Ext.CustomMessageBox.msg("salesorderinformation", bundle.getMsg("socontrol.message.successful"), bundle.getMsg("socontrol.serialnumber.successfullyRemoved"));
				c.refreshSalesOrderInfo(f.serialsAssigned, b, d);
				a.getEl().unmask()
			},
			failure: function(g, f) {
				a.getEl().unmask();
				failureHandler(g, "salesorderinformation")
			}
		})
	},
	onAssignCancel: function() {
		Ext.getCmp("assignserialnumberwindow").close()
	},
	onPrintExportSalesOrderList: function() {
		var b = Ext.getCmp("salesorderlist"),
			c = b.getSelectionModel().getSelection(),
			a = c[0];
		if (a) {
			var d = {
				resourceID: "SalesOrderController.generateSalesOrderViewReport",
				salesOrderId: a.get("key")
			};
			getResourceFile(d, "salesorderlist", null)
		}
	},
	refreshGrid: function() {
		var a = Ext.ComponentQuery.query("#salesorderlist button[id=filter]")[0];
		if (a) {
			a.fireEvent("click", a)
		}
	},
	onSalesOrderInfo: function(b) {
		var e = this;
		if (b) {
			var a = Ext.getCmp("salesorderinformation");
			a.getEl().mask("Loading...");
			var d = Ext.create("SO.model.SalesOrderVOModel");
			var c = Ext.getStore("SalesOrderStore");
			c.proxy.extraParams.resourceID = "SalesOrderController.getSalesOrderView";
			c.proxy.extraParams.salesOrderId = b.get("key");
			c.load({
				scope: this,
				callback: function(g, f, i) {
					var h = Ext.getCmp("salesOrderStandardPanel");
					d.set(g[0].data);
					h.loadRecord(d);
					if (g[0].orderLineListStore != undefined && g[0].orderLineListStore.data.length > 0) {
						g[0].orderLineListStore.getRange().forEach(function(j) {
							e.createNewOrderLinePanel(j, a.viewOnly)
						})
					}
					e.refreshSerialProgressBar("slInfoSerialProgressBar", g[0].data.totalQuantity, g[0].data.totalUnitQty);
					a.getEl().unmask()
				}
			})
		}
	},
	createNewOrderLinePanel: function(c, h) {
		var f = this,
			b = Ext.getCmp("mainPanel"),
			d = b.items.length;
		var a = Ext.create("SO.Custom.OrderLinePanel", {
			title: "Order Line Info - " + c.data.orderLine,
			margin: "5 5 5 5",
			padding: "3 3 3 3",
			id: "orderpanel" + c.data.key,
			record: c,
			viewOnly: h,
			listeners: {
				afterrender: function(i, j) {
					f.refreshSerialProgressBar("olSerialProgressBar" + c.data.key, c.data.quantity, c.data.unitsQty)
				}
			}
		});
		b.insert(d, a);
		var g = Ext.getCmp("seriallist" + c.data.key);
		if (c.data.unitsQty > 0) {
			g.getStore().proxy.extraParams.resourceID = "SalesOrderController.getSerialsByOrderLineKey";
			g.getStore().proxy.extraParams.key = c.data.key;
			g.getStore().loadPage(1)
		} else {
			g.setVisible(false)
		}
		var e = Ext.getCmp("StandardPanel" + c.data.key).getForm();
		e.loadRecord(c);
		b.doLayout()
	},
	onOpenSerialWindow: function() {
		var a = this.countSerialsProgressBar();
		var e = Ext.getCmp("quantityField").getValue(),
			b = a;
		Ext.create("SO.Custom.AddMultipleSerialNumberWindow", {
			buttonId: "onAddSerial",
			quantity: e,
			assigned: b
		}).show();
		Ext.getCmp("totalAssignedField").setValue(b + "/" + e);
		Ext.getCmp("serialList").setValue(Ext.getCmp("findSNToSelect").getValue().replace(/ *, */g, "\n"));
		Ext.getCmp("exceedValueField").setValue(canExceedsQty);
		var d = Ext.getCmp("selected").getStore().allData,
			c = [],
			f = Ext.getCmp("serialGrid").getStore();
		d.getRange().forEach(function(g) {
			c.push(g.data.serialNumber)
		});
		Ext.Ajax.request({
			type: "ajax",
			format: "json",
			method: "POST",
			url: window.windowSOContext.ajaxURL,
			params: {
				resourceID: "SalesOrderController.getSerialNumbersToAssign",
				partKey: Ext.getCmp("partKeyField").getValue(),
				assignedSerials: Ext.encode(c)
			},
			success: function(i, h) {
				var g = Ext.decode(i.responseText);
				f.loadData(g.data);
				f.proxy.extraParams.partKey = Ext.getCmp("partKeyField").getValue();
				f.proxy.extraParams.assignedSerials = Ext.encode(c);
				f.proxy.extraParams.resourceID = "SalesOrderController.getSerialNumbersToAssign"
			}
		})
	},
	onOpenSerialToRemoveWindow: function() {
		var b = Ext.getCmp("selected").store.allData.length;
		var f = Ext.getCmp("quantityField").getValue(),
			d = b;
		Ext.create("SO.Custom.AddMultipleSerialNumberWindow", {
			buttonId: "onRemoveSerial",
			customTitle: bundle.getMsg("socontrol.removeSerialNumber"),
			quantity: f,
			assigned: d
		}).show();
		Ext.getCmp("serialList").setValue(Ext.getCmp("findSNToRemove").getValue().replace(/ *, */g, "\n"));
		Ext.getCmp("totalAssignedField").setValue(d + "/" + f);
		var c = Ext.create("SO.ux.PagingStore", {
			model: "SO.model.SerialNumberModel",
			pageSize: 25,
			lastOptions: {
				params: {
					start: 0,
					limit: 25
				}
			},
			proxy: {
				type: "memory",
				reader: {
					type: "array"
				}
			},
			data: []
		});
		var e = Ext.getCmp("serialGrid");
		c.loadData(Ext.getCmp("selected").store.allData.items);
		e.reconfigure(c);
		var a = e.down("pagingtoolbar");
		a.bindStore(c);
		a.doRefresh();
		Ext.Function.defer(function() {
			Ext.getCmp("serialList").focus()
		}, 50)
	},
	onChangeSerialNumber: function() {
		var c = Ext.getCmp("serialNumberToAssign");
		var b = Ext.getCmp("serialList");
		var a = c.getRawValue();
		var d = b.getValue().trim();
		if (d.length > 0) {
			b.setValue(d + "\n" + a)
		} else {
			b.setValue(a)
		}
		c.setValue("")
	},
	onAddSerialWindow: function() {
		var b = Ext.getCmp("serialList"),
			a = Ext.getCmp("totalSerials").getValue();
		Ext.getCmp("findSNToSelect").setValue(b.getValue().trim().replace(/\n/g, ", "));
		b.setValue("");
		Ext.getCmp("addmultipleserialwindow").close();
		this.onAssignSerialButton(a)
	},
	onRemoveSerial: function() {
		var a = Ext.getCmp("serialList");
		Ext.getCmp("findSNToRemove").setValue(a.getValue().trim().replace(/\n/g, ", "));
		a.setValue("");
		Ext.getCmp("addmultipleserialwindow").close();
		this.onRemoveSerialButton()
	},
	refreshSerialProgressBar: function(e, c, d) {
		c = parseInt(c);
		d = parseInt(d);
		var a = Ext.getCmp(e),
			b = c > 0 ? (d / c) : (d > 0 ? 1 : 0);
		if (c == null || c == undefined) {
			a.updateProgress(0, " ", true)
		} else {
			a.updateProgress(b > 1 ? 1 : b, Math.round(b * 100) + "% - " + d + " of " + c, true)
		}
	},
	onAssignSerialButton: function(d) {
		container;
		var j = Ext.getCmp("findSNToSelect").getValue();
		if (j != null && j != "") {
			var f = Ext.getCmp("selected").store,
				a = Ext.getCmp("removed").store,
				b = parseInt(Ext.getCmp("quantityField").getValue()),
				k = parseInt(Ext.getCmp("unitsQtyField").getValue()),
				g = Ext.getCmp("assignserialnumberwindow"),
				h = false,
				c = this.countSerialsProgressBar();
			g.getEl().mask("Loading...");
			var i = this.removeDuplicatedOnMultipleSerials(j);
			if ((c + i.data.length <= b) || canExceedsQty) {
				for (data in container) {
					var e = i.findRecord("serialNumber", container[data].serialNumber);
					if (e) {
						e.set("containerKey", container[data].containerKey)
					}
				}
				i.getRange().forEach(function(l) {
					if (!f.getById(l.data.serialNumber)) {
						f.add(l);
						h = true
					}
				});
				if (h) {
					Ext.getCmp("removed").setDisabled(false)
				}
				Ext.getCmp("unitsQtyField").setValue(k + d);
				this.countSerialsProgressBar();
				container = [];
				f.loadPage(1);
				Ext.getCmp("findSNToSelect").setValue("");
				g.getEl().unmask()
			} else {
				g.getEl().unmask();
				Ext.CustomMessageBox.msg("assignserialnumberwindow", bundle.getMsg("socontrol.message.error"), Ext.String.format(bundle.getMsg("error.salesOrder.assignSnToSalesOrder.qty")))
			}
		} else {
			Ext.CustomMessageBox.msg("assignserialnumberwindow", bundle.getMsg("socontrol.message.error"), Ext.String.format(bundle.getMsg("validation.messages.required"), "SN"))
		}
	},
	countSerialsProgressBar: function() {
		var e = Ext.getCmp("selected").store.allData;
		var b = new Array();
		e.getRange().forEach(function(f) {
			if (f.data.isContainer) {
				var g = new Object();
				g.arrayKeysByContainer = f.data.arrayContainerKey;
				g.serialKey = f.data.id;
				b.push(g)
			}
		});
		var c = 0;
		var d = 0;
		var a = 0;
		e.getRange().forEach(function(f) {
			f.data.count = true;
			for (index in b) {
				if (b[index].arrayKeysByContainer.indexOf(f.data.containerKey) >= 0 || b[index].serialKey == f.data.containerKey) {
					f.data.count = false;
					break
				}
			}
			if (f.data.count) {
				if (f.data.isContainer) {
					d = f.data.quantity
				} else {
					a += f.data.quantity
				}
				c = c + d + a;
				a = 0;
				d = 0
			}
		});
		this.refreshSerialProgressBar("summarySerialProgressBar", Ext.getCmp("quantityField").getValue(), c);
		return c
	},
	onRemoveSerialButton: function() {
		var d = Ext.getCmp("findSNToRemove").getValue();
		if (d != null && d != "") {
			var f = Ext.getCmp("selected").store,
				b = Ext.getCmp("removed").store,
				e = Ext.getCmp("quantityField").getValue();
			errorList = [], model = null;
			var c = this.removeDuplicatedOnMultipleSerials(d);
			Ext.getCmp("findSNToRemove").setValue("");
			if (f.data.length > 0) {
				c.getRange().forEach(function(g) {
					var h = f.getById(g.data.serialNumber);
					if (h) {
						f.remove(h);
						b.add(h)
					} else {
						model = Ext.create("SO.model.ErrorListModel");
						model.set("value", g.data.serialNumber);
						errorList.push(model)
					}
				});
				this.countSerialsProgressBar();
				container = [];
				f.loadPage(1);
				if (errorList.length != 0) {
					var a = Ext.create("SO.Custom.ErrorListWindow", {
						title: bundle.getMsg("socontrol.message.errorSummary"),
						summaryLabelText: Ext.String.format(bundle.getMsg("salesOrder.assignSNResult")),
						gridHeaderValue: bundle.getMsg("socontrol.serialNumber"),
						showErrorMsg: false
					});
					a.down("grid").getStore().loadData(errorList);
					a.show()
				}
			}
		}
	},
	onRemoveContainerButton: function(b) {
		var a = this;
		Ext.Ajax.request({
			type: "ajax",
			url: window.windowSOContext.ajaxURL,
			method: "GET",
			async: true,
			format: "json",
			scope: this,
			params: {
				resourceID: "SalesOrderController.getSerialsFromContainer",
				container: b
			},
			success: function(g) {
				var c = Ext.decode(g.responseText);
				if (c.qty != undefined && c.qty > 0) {
					var h = Ext.getCmp("findCNTRToRemove").getValue();
					if (h != null && h != "") {
						var j = Ext.getCmp("selected").store,
							e = Ext.getCmp("removed").store,
							i = Ext.getCmp("quantityField").getValue();
						errorList = [], model = null;
						var f = this.removeDuplicatedOnMultipleSerials(h);
						Ext.getCmp("findCNTRToRemove").setValue("");
						j.data = Ext.getCmp("selected").store.allData;
						if (j.data.length > 0) {
							f.getRange().forEach(function(k) {
								var l = j.getById(k.data.serialNumber);
								if (l) {
									j.remove(l);
									e.add(l)
								} else {
									model = Ext.create("SO.model.ErrorListModel");
									model.set("value", k.data.serialNumber);
									errorList.push(model)
								}
							});
							this.countSerialsProgressBar();
							if (errorList.length != 0) {
								var d = Ext.create("SO.Custom.ErrorListWindow", {
									title: bundle.getMsg("socontrol.message.errorSummary"),
									summaryLabelText: Ext.String.format(bundle.getMsg("salesOrder.assignSNResult")),
									gridHeaderValue: bundle.getMsg("socontrol.serialNumber"),
									showErrorMsg: false
								});
								d.down("grid").getStore().loadData(errorList);
								d.show()
							}
						}
					}
				} else {
					Ext.CustomMessageBox.msg("assignserialnumberwindow", bundle.getMsg("socontrol.message.information"), bundle.getMsg("The container doesn't exits"));
					Ext.getCmp("findCNTRToRemove").setValue("")
				}
			},
			failure: function(c) {
				Ext.CustomMessageBox.msg("assignserialnumberwindow", bundle.getMsg("socontrol.message.information"), bundle.getMsg("Request error"))
			}
		})
	},
	removeDuplicatedOnMultipleSerials: function(c) {
		var b = Ext.create("SO.store.SerialNumberStore"),
			e = null,
			d = c.toUpperCase(),
			a = new Array();
		a = d.split(", ");
		uniqueSerialItems = a.filter(function(f, g) {
			return a.indexOf(f) == g
		});
		uniqueSerialItems.forEach(function(f) {
			e = Ext.create("SO.model.SerialNumberModel");
			e.set("serialNumber", f);
			e.set("quantity", 1);
			b.add(e)
		});
		return b
	},
	selectOrderLineOnManageSerials: function(a) {
		var b = this;
		Ext.getCmp("assignedFieldSet").setDisabled(false);
		Ext.getCmp("partNumberField").setValue(a.data.partNumber);
		Ext.getCmp("partKeyField").setValue(a.data.partKey);
		Ext.getCmp("quantityField").setValue(a.data.quantity);
		viewport = Ext.getCmp("assignserialnumberwindow");
		viewport.getEl().mask("Loading...");
		if (a) {
			Ext.Ajax.request({
				type: "ajax",
				format: "json",
				url: window.windowSOContext.ajaxURL,
				params: {
					resourceID: "SalesOrderController.getSerialsByOrderLineKeyNoLimit",
					key: a.data.key
				},
				success: function(e, d) {
					var c = Ext.decode(e.responseText);
					var g = Ext.create("SO.ux.PagingStore", {
						model: "SO.model.SerialNumberModel",
						proxy: {
							type: "memory",
							reader: {
								type: "array"
							}
						},
						data: []
					});
					g.loadData(c.data);
					var f = Ext.getCmp("assignserialnumberwindow");
					f.originalData = c.data;
					a.serialNumberList().sort("serialNumber", "ASC");
					b.populateAssignSerialPanel(a, g);
					viewport.getEl().unmask()
				}
			})
		}
	},
	itemDoubleClickToRemoved: function(h, g, d, b, f, c) {
		if (b != -1) {
			var a = Ext.getCmp("removed").store;
			var i = Ext.getCmp("selected").store;
			a.add(g);
			i.remove(g);
			this.countSerialsProgressBar()
		}
	},
	itemDoubleClickToSelected: function(h, g, d, b, f, c) {
		if (b != -1) {
			var a = Ext.getCmp("removed").store;
			var i = Ext.getCmp("selected").store;
			if (!i.getById(g.data.serialNumber.toUpperCase())) {
				i.add(g);
				a.remove(g);
				this.countSerialsProgressBar()
			} else {
				Ext.CustomMessageBox.msg("assignserialnumberwindow", bundle.getMsg("socontrol.message.information"), bundle.getMsg("socontrol.serialNumberAlreadyinList"))
			}
		}
	},
	onLoadSerialGridByShopOrder: function(c) {
		var b = Ext.getCmp("serialList"),
			a = Ext.getCmp("serialGrid").getStore();
		Ext.Ajax.request({
			type: "ajax",
			format: "json",
			method: "POST",
			url: window.windowSOContext.ajaxURL,
			params: {
				resourceID: "SalesOrderController.getSerialNumbersToAssign",
				partKey: Ext.getCmp("partKeyField").getValue(),
				shopOrder: c,
				assignedSerials: a.proxy.extraParams.assignedSerials
			},
			success: function(f, e) {
				var d = Ext.decode(f.responseText);
				a.loadData(d.data);
				a.proxy.extraParams.shopOrder = c
			}
		})
	},
	onFilterSerialGridByShopOrder: function(c) {
		var a = Ext.getCmp("serialGrid").getStore(),
			b = Ext.getCmp("serialList");
		a.clearFilter(false);
		a.filter("shopOrderNumber", Ext.String.trim(c));
		b.fireEvent("change", b)
	},
	addSerialFromGrid: function(c, a) {
		var e = c.getValue(),
			b = new RegExp("^" + a.data.serialNumber + "( )*$", "gim");
		var d = new Object();
		d.serialNumber = a.data.serialNumber;
		d.containerKey = a.data.containerKey;
		d.isContainer = a.data.isContainer;
		d.quantity = a.data.quantity;
		d.serialsByContainer = a.data.serialsByContainer;
		container.push(d);
		if (!e.match(b)) {
			if (e.length > 0) {
				c.setValue(e + "\n" + a.data.serialNumber)
			} else {
				c.setValue(a.data.serialNumber)
			}
		}
	},
	onSelectAllSerialToAdd: function() {
		var b = this,
			c = Ext.getCmp("serialGrid").getStore(),
			d = parseInt(Ext.getCmp("quantityField").getValue()),
			a = parseInt(Ext.getCmp("unitsQtyField").getValue());
		list = Ext.getCmp("serialList"), splited = value.split("\n").length, viewport = Ext.getCmp("addmultipleserialwindow");
		if ((splited + c.totalCount <= (d - a)) || canExceedsQty) {
			viewport.getEl().mask("Loading...");
			if (c.totalCount > c.pageSize) {
				Ext.Ajax.request({
					type: "ajax",
					format: "json",
					url: window.windowSOContext.ajaxURL,
					params: {
						resourceID: "SalesOrderController.getSerialNumbersToAssign",
						partKey: c.proxy.extraParams.partKey,
						shopOrder: c.proxy.extraParams.shopOrder,
						assignedSerials: c.proxy.extraParams.assignedSerials,
						selectAll: true
					},
					success: function(f) {
						var e = Ext.decode(f.responseText).data;
						if (e != undefined && e.length > 0) {
							e.forEach(function(g) {
								b.addSerialFromGrid(list, g)
							})
						}
						viewport.getEl().unmask()
					},
					failure: function(e) {
						viewport.getEl().unmask();
						failureHandler(e, "addmultipleserialwindow")
					}
				})
			} else {
				c.getRange().forEach(function(e) {
					b.addSerialFromGrid(list, e)
				});
				viewport.getEl().unmask()
			}
		} else {
			Ext.CustomMessageBox.msg("addmultipleserialwindow", bundle.getMsg("socontrol.message.error"), Ext.String.format(bundle.getMsg("error.salesOrder.assignSnToSalesOrder.qty")))
		}
	},
	onSelectAllSerialToRemove: function() {
		var a = this,
			c = Ext.getCmp("serialGrid").getStore(),
			b = Ext.getCmp("serialList");
		if (c.getCount() > 0) {
			c.getRange().forEach(function(d) {
				a.addSerialFromGrid(b, d)
			})
		}
	},
	onEnterList: function(b, c) {
		var d = b.split("\n");
		var a = d[d.length - 1];
		if (a == "") {
			c.stopEvent()
		}
	},
	onSalesOrderFilterFromOracle: function() {
		var a = Ext.getCmp("salesOrderField").getValue(),
			c = Ext.getCmp("soNumberField").getValue(),
			d = Ext.getCmp("pNumberField").getValue(),
			b = Ext.getCmp("salesOrderGrid").getStore();
		b.proxy.extraParams.resourceID = "SalesOrderController.onSalesOrderFilterFromOracle";
		b.proxy.extraParams.salesOrder = a;
		b.proxy.extraParams.shopOrder = c;
		b.proxy.extraParams.partNumber = d;
		b.loadPage(1, {
			callback: function(f, e, g) {
				if (g) {
					serialGrid.setVisible(true)
				} else {
					serialGrid.setVisible(false)
				}
			}
		})
	},
	onPushSalesOrderFromOracle: function() {
		var c = Ext.getCmp("salesOrderGrid").getSelectionModel().getSelection(),
			b = [],
			a = Ext.getCmp("pushsalesorderwindow"),
			d = this;
		a.getEl().mask("Loading...");
		c.forEach(function(e) {
			b.push(e.data.key)
		});
		Ext.Ajax.request({
			type: "ajax",
			format: "json",
			url: window.windowSOContext.ajaxURL,
			params: {
				resourceID: "SalesOrderController.onPushSalesOrderFromOracle",
				filtered: c
			},
			success: function(e) {
				a.getEl().unmask();
				a.close();
				d.refreshGrid()
			},
			failure: function(e) {
				a.getEl().unmask();
				failureHandler(e, "pushsalesorderwindow")
			}
		})
	},
	onClearResearch: function() {
		Ext.getCmp("salesOrderField").setValue("");
		Ext.getCmp("soNumberField").setValue("");
		Ext.getCmp("pNumberField").setValue("");
		var a = Ext.getCmp("salesOrderGrid").getStore();
		a.removeAll()
	}
});
Ext.define("SO.model.ReleaseWizardModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "createSerial",
		type: "boolean",
		defaultValue: true
	}, {
		name: "createSkeleton",
		type: "boolean"
	}, {
		name: "batchRelease",
		type: "boolean"
	}, {
		name: "selectSalesOrder",
		type: "boolean"
	}, {
		name: "releaseType",
		type: "int"
	}, {
		name: "shopOrder"
	}, {
		name: "byPartMax"
	}, {
		name: "byPartLatest"
	}, {
		name: "byPartStartSerialNumberMax"
	}, {
		name: "byPartStartSerialNumberLatest"
	}, {
		name: "byPartStartSerialNumber"
	}, {
		name: "byAlgorithmMax"
	}, {
		name: "byAlgorithmLatest"
	}, {
		name: "byAlgorithmStartSerialNumberMax"
	}, {
		name: "byAlgorithmStartSerialNumberLatest"
	}, {
		name: "byAlgorithmStartSerialNumber"
	}, {
		name: "algorithmKey",
		type: "int"
	}, {
		name: "fullRelease",
		type: "boolean",
		defaultValue: true
	}, {
		name: "algorithmName"
	}, {
		name: "isPartBased",
		type: "boolean"
	}, {
		name: "isInitiallyPartBased",
		type: "boolean"
	}, {
		name: "invalidRelease",
		type: "boolean"
	}, {
		name: "errorAction"
	}, {
		name: "errorDetail"
	}, {
		name: "errorReplace"
	}, {
		name: "startSerialNumber"
	}, {
		name: "createSerialFile",
		type: "boolean",
		defaultValue: true
	}, {
		name: "printSerials",
		type: "boolean",
		defaultValue: false
	}, {
		name: "createNotes",
		type: "boolean",
		defaultValue: true
	}, {
		name: "showRevisionStep",
		type: "boolean"
	}, {
		name: "defineUsl",
		type: "boolean"
	}, {
		name: "startSerialAlgMaxWarning",
		type: "boolean"
	}, {
		name: "startSerialAlgLatestWarning",
		type: "boolean"
	}, {
		name: "startSerialPartMaxWarning",
		type: "boolean"
	}, {
		name: "startSerialPartLatestWarning",
		type: "boolean"
	}, {
		name: "revisionControlled",
		type: "boolean"
	}, {
		name: "releaseError",
		type: "boolean"
	}, {
		name: "revisionControlled",
		type: "boolean"
	}, {
		name: "panelQuantity",
		type: "int"
	}, {
		name: "auxiliaryRelease",
		type: "boolean",
		defaultValue: false
	}, {
		name: "statusUpdateOnly",
		type: "boolean"
	}, {
		name: "traceabilityTestOk",
		type: "boolean",
		defaultValue: true
	}, {
		name: "traceabilityTestError",
		type: "boolean"
	}, {
		name: "oneTravelerPerUnit",
		type: "boolean"
	}, {
		name: "wipTravelerPerUnit",
		type: "boolean"
	}, {
		name: "printTraveler",
		type: "boolean"
	}, {
		name: "hasBOM",
		type: "boolean"
	}, {
		name: "routeAssiged",
		type: "boolean"
	}, {
		name: "printCurrentSerials",
		type: "boolean"
	}, {
		name: "soLinkage",
		type: "boolean"
	}, {
		name: "isSOLinked",
		type: "boolean"
	}, {
		name: "oneTravelerPerOrder",
		type: "boolean"
	}, {
		name: "ATOShopOrderNumber",
		type: "boolean"
	}, {
		name: "skeletonRelease",
		type: "boolean"
	}, {
		name: "oracleSO",
		type: "boolean"
	}, {
		name: "createAssembliesAutomatically",
		type: "boolean"
	}, {
		name: "usl",
		type: "int",
		defaultValue: 0
	}, {
		name: "orderLineKey",
		type: "int",
		defaultValue: 0
	}],
	isPartialRelease: function() {
		if (this.get("shopOrder").get("increasedQuantity") == 0) {
			return this.get("quantitySerial") > 0
		} else {
			return false
		}
	}
});
Ext.define("SO.store.ReleaseNotesStore", {
	extend: Ext.data.Store,
	model: "SO.model.ReleaseNotes",
	remoteSort: false,
	autoLoad: false,
	sorters: [{
		property: "createDttm",
		direction: "DESC"
	}],
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "ReleaseNotesController.getReleaseNotes"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			messageProperty: "message",
			idProperty: "id",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true
		})
	},
	listeners: {
		write: function(b, a) {
			var c = Ext.decode(a.response.responseText);
			if (!c.success) {
				Ext.MessageBox.show({
					title: "Error",
					msg: c.message,
					icon: Ext.MessageBox.ERROR,
					buttons: Ext.Msg.OK
				})
			}
		}
	}
});
var previousStack = new Array();
var releaseWizardModel = "";
Ext.define("SO.controller.ReleaseWizardController", {
	extend: Ext.app.Controller,
	stores: ["ReleaseNotesStore"],
	models: [],
	views: ["ShopOrderRelease.ShopOrderReleaseList", "ReleaseShopOrder.ReleaseWindow", "ReleaseShopOrder.StepsPanel", "ReleaseShopOrder.Step1Form", "ReleaseShopOrder.StartSnStep", "ReleaseShopOrder.QuantityStep", "ReleaseShopOrder.SetupSalesOrderLineStep", "ReleaseShopOrder.SetupUSLStep", "ReleaseShopOrder.SummaryStep", "ReleaseShopOrder.ErrorWarningStep", "ReleaseShopOrder.SetupRevisionStep", "ReleaseShopOrder.ReleaseNotesStep", "ReleaseShopOrder.GenericResultStep", "ReleaseShopOrder.ReleaseFailStep", "ReleaseShopOrder.AuxReleaseQtyStep"],
	init: function() {
		Ext.ComponentQuery.pseudos.invalid = function(d) {
			var e = 0,
				b = d.length,
				f, a = [];
			for (; e < b; e++) {
				if (!(f = d[e]).isValid()) {
					a.push(f)
				}
			}
			return a
		}, this.control({
			"releasewindow button[action=onNextStep]": {
				click: function(b, c, a) {
					this.onNextStep()
				}
			},
			"releasewindow button[action=onPrevStep]": {
				click: function(b, c, a) {
					this.onPrevStep()
				}
			},
			"releasewindow button[action=onFinishReleaseWizard]": {
				click: function(b, c, a) {
					this.onFinishReleaseWizard()
				}
			},
			"releasewindow button[action=onCancelReleaseWizard]": {
				click: function(b, c, a) {
					this.onCancelReleaseWizard()
				}
			},
			"releasewindow step1form checkbox": {
				change: function(d, c, a, b) {
					this.changeSerialRulesCB(d, c, a, b)
				}
			},
			"releasewindow radio[name=releaseType]": {
				change: function(d, c, a, b) {
					this.changeReleaseTypeRB(d, c, a, b)
				}
			},
			"releasewindow radio[name=algStartingType]": {
				change: function(d, c, a, b) {
					this.changeAlgStartingTypeRB(d, c, a, b)
				}
			},
			"releasewindow radio[name=partStartingType]": {
				change: function(d, c, a, b) {
					this.changePartStartingTypeRB(d, c, a, b)
				}
			},
			"releasewindow radio[name=fullPartialReleaseType]": {
				change: function(d, c, a, b) {
					this.changeFullPartialReleaseTypeRB(d, c, a, b)
				}
			},
			"releasewindow checkbox[name=printTravelerOptions]": {
				change: function(d, c, a, b) {
					this.changePrintTravelerOptionsCB(d, c, a, b)
				}
			},
			"#releasewindow": {
				beforedestroy: this.unlockReleaseProcess
			}
		});
		this.application.on({
			onShopOrderReleaseClick: this.onShopOrderReleaseClick,
			scope: this
		})
	},
	onShopOrderReleaseClick: function(a, c) {
		var b = Ext.getCmp("somainwindow");
		b.getEl().mask("Loading...");
		Ext.Ajax.request({
			scope: this,
			async: true,
			url: window.windowSOContext.ajaxURL,
			params: {
				resourceID: "ShopOrderReleaseController.preReleaseCheck",
				shopOrderNumber: a.get("shopOrderNumber"),
				isErp: a.get("oracleShopOrder")
			},
			success: function(d) {
				var e = Ext.decode(d.responseText);
				a.set("partNumberString", a.getPartNumber().get("partNumber"));
				if (a.get("revisionControlled") == 0) {
					a.set("revision", "")
				}
				releaseWizardModel = Ext.create("SO.model.ReleaseWizardModel");
				releaseWizardModel.set("shopOrder", a);
				releaseWizardModel.set("auxiliaryRelease", typeof(c) != "undefined" ? c : false);
				releaseWizardModel.set(e);
				if (!releaseWizardModel.get("noRouteAssignedRelease") && !releaseWizardModel.get("partHasRoute")) {
					releaseWizardModel.set("invalidRelease", true);
					releaseWizardModel.set("errorAction", "validation.messages.noRouteAssignedToAssembly")
				}
				b.getEl().unmask();
				this.shopOrderReleaseClick(a, c)
			},
			failure: function(d) {
				b.getEl().unmask();
				this.failureHandler(d, "somainwindow")
			}
		})
	},
	shopOrderReleaseClick: function(c, f) {
		var d = this,
			b = Ext.widget("releasewindow", {
				shopOrder: c
			}),
			e = Ext.getCmp("soInfoPanel").getForm();
		e.loadRecord(c);
		b.show();
		b.getEl().mask("loading ...");
		var a = Ext.getCmp("stepspanel");
		a.add(Ext.widget("step1form", {
			evaluate: function(g) {
				return g.data.invalidRelease != true
			},
			prepare: function(j) {
				var o = Ext.getCmp("defineUsl"),
					p = Ext.getCmp("defineSalesOrder"),
					m = Ext.getCmp("createSkeleton"),
					n = Ext.getCmp("nonSerializedBath"),
					h = Ext.getCmp("showRevisionStep"),
					q = releaseWizardModel.data.defaultOptions.split(","),
					k, g = {
						def_usl: o,
						def_order_line: p,
						def_rev: h,
						non_sn_batch: n,
						create_skl: m
					};
				if (typeof(o) != "undefined") {
					o.setDisabled(releaseWizardModel.data.shopOrder.data.createSkeleton || releaseWizardModel.data.shopOrder.data.batchRelease)
				}
				if (typeof(p) != "undefined") {
					p.setDisabled(releaseWizardModel.data.shopOrder.data.createSkeleton)
				}
				if (typeof(n) != "undefined") {
					n.setDisabled(releaseWizardModel.data.shopOrder.data.createSkeleton)
				}
				if (typeof(m) != "undefined") {
					m.setDisabled(releaseWizardModel.data.shopOrder.data.batchRelease || releaseWizardModel.data.shopOrder.data.createSkeleton || releaseWizardModel.data.shopOrder.data.isSkeletonRelease || releaseWizardModel.data.shopOrder.data.anotherSOLink);
					m.setValue(releaseWizardModel.data.shopOrder.data.createSkeleton || releaseWizardModel.data.shopOrder.data.isSkeletonRelease || releaseWizardModel.data.shopOrder.data.anotherSOLink)
				}
				for (var l = 0; l < q.length; ++l) {
					k = g[q[l]];
					if (typeof(k) != "undefined" && !k.isDisabled()) {
						k.setValue(releaseWizardModel.data.defaultOptions.search(q[l]) > -1)
					}
				}
			},
			beforeNextStep: function(i) {
				if (i.get("invalidRelease") == true && i.get("errorAction") == "validation.messages.noRouteAssignedToAssembly") {
					return
				}
				Ext.Ajax.request({
					scope: this,
					async: false,
					url: window.windowSOContext.ajaxURL,
					method: "GET",
					format: "json",
					params: {
						resourceID: "ShopOrderReleaseController.checkRelease",
						id: c.data.id,
						createSerial: Ext.getCmp("createSerial").getValue(),
						auxiliaryRelease: i.get("auxiliaryRelease"),
						createSkeleton: Ext.getCmp("createSkeleton").getValue(),
						batchRelease: Ext.getCmp("nonSerializedBath") ? Ext.getCmp("nonSerializedBath").getValue() : false
					},
					success: function(t) {
						i.set(Ext.decode(t.responseText).data);
						if (i.get("isPartBased")) {
							i.set("releaseType", 0);
							i.set("isInitiallyPartBased", true)
						} else {
							i.set("releaseType", 1);
							i.set("isInitiallyPartBased", false)
						}
					},
					failure: function(t) {
						i.set("invalidRelease", true);
						var z = "",
							w = 0,
							v = "",
							y = new Array(),
							x = Ext.decode(t.responseText);
						if (x.messageAttributes != 0) {
							for (var u in x.messageAttributes) {
								if (u == "message") {
									v = x.messageAttributes[u]
								} else {
									y[w] = x.messageAttributes[u];
									w++
								}
							}
							z = bundle.getMsg("socontrol.message.error")
						}
						i.set("errorAction", z != "" ? z : "Sorry, an unexpected error happened when checking the release details.")
					}
				});
				var o = Ext.getCmp("showRevisionStep");
				i.set("showRevisionStep", Ext.getCmp("showRevisionStep") ? (o.value && !o.disabled) : false);
				i.set("defineUsl", Ext.getCmp("defineUsl") ? Ext.getCmp("defineUsl").getValue() : false);
				i.set("selectSalesOrder", Ext.getCmp("defineSalesOrder").getValue());
				i.set("createSkeleton", Ext.getCmp("createSkeleton").getValue());
				i.set("batchRelease", Ext.getCmp("nonSerializedBath") ? Ext.getCmp("nonSerializedBath").getValue() : false);
				var m = false;
				if (!Ext.getCmp("createSkeleton").getValue() && i.get("shopOrder").get("algorithmNumber") != null && i.get("shopOrder").get("algorithmNumber") != 0) {
					m = true
				}
				i.set("createSerial", m);
				if (!i.get("auxiliaryRelease") && i.isPartialRelease()) {
					var s = Ext.getCmp("createAssembliesAutomatically") ? Ext.getCmp("createAssembliesAutomatically").getValue() : false;
					var k = Ext.getCmp("printSerials") ? Ext.getCmp("printSerials").getValue() : false;
					var p = Ext.getCmp("printTravelerOnePerUnit") ? Ext.getCmp("printTravelerOnePerUnit").getValue() : false;
					var g = Ext.getCmp("printTravelerWip") ? Ext.getCmp("printTravelerWip").getValue() : false;
					var j = Ext.getCmp("printTravelerOnePerOrder") ? Ext.getCmp("printTravelerOnePerOrder").getValue() : false;
					var r = Ext.getCmp("createSerialFile") ? Ext.getCmp("createSerialFile").getValue() : false;
					var n = true;
					var l = Ext.getCmp("createNotes") ? Ext.getCmp("createNotes").getValue() : true;
					var q = Ext.getCmp("soLinkage") ? Ext.getCmp("soLinkage").getValue() : false;
					i.set("createAssembliesAutomatically", s);
					i.set("printSerials", k);
					if (p || g || j) {
						i.set("printTraveler", true)
					} else {
						i.set("printTraveler", false)
					}
					i.set("createSerialFile", r);
					i.set("createNotes", l);
					i.set("soLinkage", q);
					var h = ((i.get("oneTravelerPerUnit") || i.get("wipTravelerPerUnit")) && i.get("shopOrder").get("oracleShopOrder") && i.get("hasBOM")) || i.get("oneTravelerPerOrder");
					Ext.Ajax.request({
						scope: this,
						async: false,
						url: window.windowSOContext.ajaxURL,
						method: "POST",
						format: "json",
						params: {
							resourceID: "ShopOrderReleaseController.release",
							shopOrder: Ext.JSON.encode(releaseWizardModel.get("shopOrder").data),
							qtyToRelease: i.get("quantitySerial"),
							createSkeleton: i.get("createSkeleton"),
							statusUpdateOnly: n,
							travelerNeeded: h,
							batchRelease: i.get("batchRelease"),
							createAssembliesAutomatically: i.get("createAssembliesAutomatically"),
							usl: i.get("usl"),
							startSerialNumber: "",
							panelQuantity: 0,
							createSerial: false,
							isPartBased: false,
							orderLineKey: i.get("orderLineKey")
						},
						success: function(t) {
							respText = Ext.decode(t.responseText);
							if (respText.releaseError) {
								i.set("invalidRelease", true);
								i.set("releaseError", true);
								i.set("errorAction", respText.errorAction);
								i.set("errorReplace", respText.errorReplace);
								i.set("errorDetail", respText.errorDetail)
							} else {
								i.set("invalidRelease", false);
								i.set("releaseError", false);
								i.get("shopOrder").set("firstSerialNumber", respText.firstSerialNumber);
								i.get("shopOrder").set("lastSerialNumber", respText.lastSerialNumber);
								i.set("startSerialNumber", respText.firstSNCreated)
							}
						}
					})
				}
			}
		}));
		a.add(Ext.widget("errorwarningstep", {
			evaluate: function(g) {
				return Ext.isDefined(g.data.traceabilityTestOk) && !g.data.traceabilityTestOk
			},
			prepare: function(g) {
				var l = "",
					j = "";
				if (g.get("traceabilityTestError")) {
					l = "error"
				} else {
					if (!g.get("traceabilityTestError")) {
						l = "warning"
					}
				}
				for (var k = 0; k < g.get("traceabilityTestBeans").length; k++) {
					j += g.get("traceabilityTestBeans")[k].partNumber + ": " + g.get("traceabilityTestBeans")[k].missing + "<br>" + g.get("traceabilityTestBeans")[k].refDesig + "<br>" + bundle.getMsg("socontrol.release.wizard.requiredQty") + ": " + g.get("traceabilityTestBeans")[k].qtyRequired + "<br>" + bundle.getMsg("socontrol.release.wizard.asmFoundQty") + ": " + g.get("traceabilityTestBeans")[k].asmFoundQty + "<br><br>"
				}
				var h = Ext.getCmp("errorwarningstep");
				h.typeMessage = l;
				h.errorWarningMessage = j;
				h.reloadComponent()
			},
			afterPrepare: function(h) {
				if (h.get("traceabilityTestError")) {
					var g = Ext.getCmp("releaseNextBtn"),
						i = Ext.getCmp("releaseFinishBtn");
					g.setDisabled(true);
					i.setDisabled(false)
				}
			}
		}));
		a.add(Ext.widget("startsnstep", {
			evaluate: function(g) {
				return g.get("createSerial") && (!g.get("invalidRelease") || g.get("errorAction") == "error.progress.socontrol.startSerialAlreadyExists") && (g.get("auxiliaryRelease") || !g.isPartialRelease()) && !g.get("reateSkeleton") && !g.get("batchRelease")
			},
			prepare: function(g) {
				this.reloadComponent()
			},
			beforeNextStep: function(h) {
				var j = Ext.getCmp("algorithmRT");
				var l = Ext.getCmp("partNumberRT");
				var g = "";
				if (j.getValue()) {
					var i = Ext.getCmp("algStartingSerialNumber");
					g = i.getValue();
					h.set("byAlgorithmStartSerialNumber", g);
					h.set("isPartBased", false)
				} else {
					if (l.getValue()) {
						var k = Ext.getCmp("partStartingSerialNumber");
						g = k.getValue();
						h.set("byPartStartSerialNumber", g);
						h.set("isPartBased", true)
					}
				}
				h.set("startSerialNumber", g)
			}
		}));
		a.add(Ext.widget("auxreleaseqtystep", {
			evaluate: function(g) {
				return (!g.get("invalidRelease") || g.get("errorAction") == "error.progress.socontrol.startSerialAlreadyExists") && g.get("auxiliaryRelease")
			},
			beforeNextStep: function(g) {
				var h = Ext.getCmp("auxreleaseqty");
				g.set("panelQuantity", h.getValue());
				g.set("quantity", h.getValue())
			}
		}));
		a.add(Ext.widget("quantitystep", {
			evaluate: function(g) {
				return (!g.get("invalidRelease") || g.get("errorAction") == "error.progress.socontrol.startSerialAlreadyExists") && !g.isPartialRelease() && !g.get("auxiliaryRelease")
			},
			beforeNextStep: function(g) {
				var h = Ext.getCmp("fullReleaseType");
				var i = Ext.getCmp("quantityPartialReleaseType");
				g.set("fullRelease", h.getValue());
				if (!h.getValue()) {
					g.set("quantity", i.getValue())
				} else {
					g.set("quantity", g.get("shopOrder").get("increasedQuantity") > 0 ? g.get("shopOrder").get("increasedQuantity") : g.get("shopOrder").get("quantity"))
				}
			}
		}));
		a.add(Ext.widget("setuprevisionstep", {
			evaluate: function(g) {
				return (!g.get("invalidRelease") || g.get("errorAction") == "error.progress.socontrol.startSerialAlreadyExists") && Ext.isDefined(g.data.showRevisionStep) && g.data.showRevisionStep && (!g.isPartialRelease() || g.get("auxiliaryRelease"))
			},
			beforeNextStep: function(h) {
				var g = Ext.getCmp("revisionValue");
				if (typeof(g) != "undefined") {
					h.get("shopOrder").set("revision", g.getValue())
				}
			}
		}));
		a.add(Ext.widget("setupsalesorderlinestep", {
			evaluate: function(g) {
				return (!g.get("invalidRelease") || g.get("errorAction") == "error.progress.socontrol.startSerialAlreadyExists") && Ext.isDefined(g.data.selectSalesOrder) && g.data.selectSalesOrder && (!g.isPartialRelease() || g.get("auxiliaryRelease"))
			},
			beforeNextStep: function(h) {
				var g = Ext.getCmp("selectSalesOrder");
				h.set("orderLineKey", g.getValue())
			}
		}));
		a.add(Ext.widget("setupuslstep", {
			evaluate: function(g) {
				return (!g.get("invalidRelease") || g.get("errorAction") == "error.progress.socontrol.startSerialAlreadyExists") && Ext.isDefined(g.data.defineUsl) && g.data.defineUsl && (!g.isPartialRelease() || g.get("auxiliaryRelease"))
			},
			prepare: function(g) {
				var h = releaseWizardModel.get("shopOrder").get("usl");
				if (h > 0) {
					var i = Ext.getCmp("unitStartedLocation");
					if (i.getValue() < 1) {
						i.setValue(h)
					}
				}
			},
			beforeNextStep: function(g) {
				var h = Ext.getCmp("unitStartedLocation");
				g.set("usl", h.getValue())
			}
		}));
		a.add(Ext.widget("summarystep", {
			hideInfoPanel: true,
			evaluate: function(g) {
				return (!g.get("invalidRelease") || g.get("errorAction") == "error.progress.socontrol.startSerialAlreadyExists") && (!g.isPartialRelease() || g.get("auxiliaryRelease"))
			},
			prepare: function(g) {
				this.reloadComponent()
			},
			beforePrevStep: function(g) {
				g.set("invalidRelease", false);
				g.set("releaseError", false);
				if (g.get("errorAction") != "error.progress.socontrol.startSerialAlreadyExists") {
					g.set("errorAction", "")
				}
			},
			beforeNextStep: function(i) {
				var p = Ext.getCmp("createAssembliesAutomatically") ? Ext.getCmp("createAssembliesAutomatically").getValue() : false;
				var k = Ext.getCmp("printSerials") ? Ext.getCmp("printSerials").getValue() : false;
				var m = Ext.getCmp("printTravelerOnePerUnit") ? Ext.getCmp("printTravelerOnePerUnit").getValue() : false;
				var g = Ext.getCmp("printTravelerWip") ? Ext.getCmp("printTravelerWip").getValue() : false;
				var j = Ext.getCmp("printTravelerOnePerOrder") ? Ext.getCmp("printTravelerOnePerOrder").getValue() : false;
				var o = Ext.getCmp("createSerialFile") ? Ext.getCmp("createSerialFile").getValue() : false;
				var l = Ext.getCmp("createNotes") ? Ext.getCmp("createNotes").getValue() : false;
				var n = Ext.getCmp("soLinkage") ? Ext.getCmp("soLinkage").getValue() : false;
				i.set("createAssembliesAutomatically", p);
				i.set("printSerials", k);
				if (m || g || j) {
					i.set("printTraveler", true)
				} else {
					i.set("printTraveler", false)
				}
				i.set("createSerialFile", o);
				i.set("createNotes", l);
				i.set("soLinkage", n);
				var h = ((i.get("oneTravelerPerUnit") || i.get("wipTravelerPerUnit")) && i.get("shopOrder").get("oracleShopOrder") && i.get("hasBOM")) || i.get("oneTravelerPerOrder");
				d.releaseInProcess = true;
				Ext.Ajax.request({
					scope: this,
					async: true,
					url: window.windowSOContext.ajaxURL,
					method: "POST",
					format: "json",
					params: {
						resourceID: "ShopOrderReleaseController.release",
						shopOrder: Ext.JSON.encode(releaseWizardModel.get("shopOrder").data),
						qtyToRelease: i.get("quantity"),
						startSerialNumber: i.get("startSerialNumber"),
						panelQuantity: i.get("panelQuantity"),
						createSerial: i.get("createSerial"),
						createSkeleton: i.get("createSkeleton"),
						isPartBased: i.get("isPartBased"),
						statusUpdateOnly: i.get("statusUpdateOnly"),
						travelerNeeded: h,
						batchRelease: i.get("batchRelease"),
						createAssembliesAutomatically: i.get("createAssembliesAutomatically"),
						usl: i.get("usl"),
						orderLineKey: i.get("orderLineKey")
					},
					success: function(q) {
						d.releaseInProcess = false;
						respText = Ext.decode(q.responseText);
						if (respText.releaseError) {
							i.set("invalidRelease", true);
							i.set("releaseError", true);
							i.set("errorAction", respText.errorAction);
							i.set("errorReplace", respText.errorReplace);
							i.set("errorDetail", respText.errorDetail)
						} else {
							i.set("invalidRelease", false);
							i.set("releaseError", false);
							i.get("shopOrder").set("firstSerialNumber", respText.firstSerialNumber);
							i.get("shopOrder").set("lastSerialNumber", respText.lastSerialNumber);
							i.set("startSerialNumber", respText.firstSNCreated)
						}
						if (!i.get("releaseError") && !i.get("createNotes") && i.get("printTraveler")) {
							SO.controller.ReleaseWizardController.printTravelerRelease()
						}
						if (!i.get("releaseError")) {
							SO.controller.ReleaseWizardController.showLinkage()
						}
						d.goToNextStep(Ext.getCmp("stepspanel").getLayout().getActiveItem())
					},
					failure: function() {
						d.releaseInProcess = false
					}
				});
				d.renewSessionOnRelease();
				return false
			}
		}));
		a.add(Ext.widget("releasefailstep", {
			evaluate: function(g) {
				return ((Ext.isDefined(g.get("invalidRelease")) && g.get("invalidRelease") == true) && g.get("errorAction") != "error.progress.socontrol.startSerialAlreadyExists")
			},
			prepare: function(g) {
				var i = Ext.String.format(bundle.getMsg(g.get("errorAction")), g.get("errorReplace"));
				var h = Ext.getCmp("releasefailstep");
				h.errorMessage = i;
				h.reloadComponent()
			},
			afterPrepare: function(h) {
				if (h.get("traceabilityTestError")) {
					var j = Ext.getCmp("releasePreviousBtn"),
						g = Ext.getCmp("releaseNextBtn"),
						i = Ext.getCmp("releaseFinishBtn");
					j.setDisabled(true);
					g.setDisabled(true);
					i.setDisabled(false)
				}
			}
		}));
		a.add(Ext.widget("genericresultstep", {
			disablePrevious: true,
			disableCancel: true,
			evaluate: function(g) {
				return (!g.get("invalidRelease") || g.get("errorAction") == "error.progress.socontrol.startSerialAlreadyExists")
			},
			prepare: function(g) {
				if (!g.get("auxiliaryRelease") && g.isPartialRelease()) {
					this.loadPartialReleaseResultCmp()
				} else {
					var h = g.get("shopOrder"),
						k = [];
					Ext.Ajax.request({
						scope: this,
						async: false,
						url: window.windowSOContext.ajaxURL,
						method: "GET",
						format: "json",
						params: {
							resourceID: "SerialNumberController.getReleasedSerialNumbers",
							shopOrder: Ext.JSON.encode(releaseWizardModel.get("shopOrder").data),
							startSerialNumber: g.get("startSerialNumber")
						},
						success: function(m) {
							k = Ext.decode(m.responseText)
						}
					});
					var l = false;
					if (!g.get("auxiliaryRelease")) {
						var j = h.get("quantity") - h.get("quantitySerial"),
							i = "";
						if (releaseWizardModel.get("batchRelease")) {
							if (releaseWizardModel.get("fullRelease") || j == h.get("quantity")) {
								i = Ext.String.format(bundle.getMsg("socontrol.release.wizard.releaseResultsStep.batchReleaseOk"), h.get("firstSerialNumber"), h.get("lastSerialNumber"))
							} else {
								i = Ext.String.format(bundle.getMsg("socontrol.release.wizard.releaseResultsStep.batchReleasePartial"), k.length, g.get("startSerialNumber"), h.get("lastSerialNumber"));
								l = true
							}
						} else {
							if (j != k.length) {
								i = Ext.String.format(bundle.getMsg("socontrol.release.wizard.releaseResultsStep.releasePartial"), j, k.length, g.get("startSerialNumber"), h.get("lastSerialNumber"));
								l = true
							} else {
								i = Ext.String.format(bundle.getMsg("socontrol.release.wizard.releaseResultsStep.releaseOk"), h.get("firstSerialNumber"), h.get("lastSerialNumber"))
							}
						}
					} else {
						i = Ext.String.format(bundle.getMsg("socontrol.release.wizard.releaseResultsStep.releaseOk"), h.get("firstSerialNumber"), h.get("lastSerialNumber"))
					}
					this.loadReleaseResultCmp(i, l);
					if (g.get("createSerialFile")) {
						getResourceFile({
							resourceID: "SerialNumberController.releaseSerialNumbersFile",
							printCurrent: g.get("printCurrentSerials"),
							id: h.get("id"),
							shopOrderNumber: h.get("shopOrderNumber"),
							partNumber: h.getPartNumber().get("partNumber"),
							revision: h.get("revision"),
							startSerialNumber: g.get("startSerialNumber")
						}, "genericresultstep", null)
					}
					if (g.get("printSerials")) {
						Ext.widget("printlabelswindow", {
							sn_data: g.get("printCurrentSerials") ? k : null,
							shopOrderId: h.get("id"),
							partKey: h.get("partId")
						}).show();
						Ext.getCmp("printlabelsform").getForm().isValid()
					}
				}
			}
		}));
		a.add(Ext.widget("releasenotesstep", {
			hideInfoPanel: true,
			controlMask: true,
			disablePrevious: true,
			disableCancel: true,
			evaluate: function(g) {
				return g.data.createNotes
			},
			prepare: function(g) {
				var h = Ext.getStore("ReleaseNotesStore");
				h.getProxy().extraParams.shopOrderKey = g.data.shopOrder.data.id;
				h.on({
					load: function(k, j, n, l) {
						var m = Ext.getCmp("releasenotesstepform");
						if (j) {
							if (j.length > 0) {
								m.loadRecord(j[0])
							} else {
								var i = Ext.create("SO.model.ReleaseNotes");
								i.set("shopOrderKey", g.data.shopOrder.data.id);
								i.set("notes", "");
								i.set("createUser", "");
								i.set("createDttm", "");
								m.loadRecord(i)
							}
						}
						Ext.getCmp("releasewindow").getEl().unmask()
					}
				});
				h.getProxy().extraParams.resourceID = "ReleaseNotesController.findAllReleaseNotes";
				h.load()
			},
			beforeNextStep: function(g) {
				var j = Ext.getCmp("releasenotesstepform").getForm();
				if (typeof(j) != "undefined") {
					if (typeof(j.getRecord()) != "undefined") {
						if (j.getValues().notes != j.getRecord().data.notes) {
							j.getRecord().set({
								notes: j.getValues().notes
							});
							var h = j.getRecord();
							var k = Ext.getStore("ReleaseNotesStore");
							k.getProxy().extraParams.resourceID = "ReleaseNotesController.save";
							k.add(h);
							k.sync()
						}
						if (releaseWizardModel.get("printTraveler")) {
							var i = SO.controller.ReleaseWizardController;
							i.printTravelerRelease()
						}
					}
				}
			}
		}));
		this.goToNextStep()
	},
	renewSessionOnRelease: function() {
		var a = this,
			c = Liferay.Session;
		if (typeof(c) == "undefined" || a.releaseInProcess != true) {
			return
		}
		var b = 55000;
		console.log("[" + Ext.util.Format.date(new Date(), "y-m-d H:m:s:ms") + "] SO RELEASE - Renewing the Session in " + b + " ms.");
		setTimeout(function() {
			if (a.releaseInProcess == true) {
				c.extend();
				console.log("[" + Ext.util.Format.date(new Date(), "y-m-d H:m:s:ms") + "] SO RELEASE - Session is Renewed");
				a.renewSessionOnRelease()
			}
		}, b)
	},
	onCancelReleaseWizard: function() {
		Ext.getCmp("releasewindow").close();
		this.getController("ShopOrderReleaseController").refreshGrid()
	},
	onFinishReleaseWizard: function() {
		var a = Ext.getCmp("stepspanel"),
			b = a.getLayout().getActiveItem();
		invalidFields = b.query("field:invalid");
		if (invalidFields.length > 0) {
			return
		}
		if (Ext.isDefined(b.beforeNextStep)) {
			b.beforeNextStep(releaseWizardModel)
		}
		Ext.getCmp("releasewindow").close();
		this.getController("ShopOrderReleaseController").refreshGrid();
		if (releaseWizardModel.get("auxiliaryRelease")) {
			this.application.fireEvent("onFinishAuxiliaryRelease")
		}
	},
	unlockReleaseProcess: function() {
		Ext.Ajax.request({
			scope: this,
			async: false,
			url: window.windowSOContext.ajaxURL,
			params: {
				resourceID: "ShopOrderReleaseController.unlockReleaseProcess",
				shopOrderKey: releaseWizardModel.get("shopOrder").get("id")
			}
		})
	},
	onPrevStep: function() {
		var e = Ext.getCmp("stepspanel"),
			g = e.getLayout().getActiveItem(),
			c = true;
		if (Ext.isDefined(g.beforePrevStep)) {
			c = g.beforePrevStep(releaseWizardModel)
		}
		if (c == false) {
			return
		}
		var e = Ext.getCmp("stepspanel"),
			a = e.items.indexOfKey(e.getLayout().getActiveItem().id) - 1,
			b = previousStack.pop();
		var f = Ext.getCmp("soInfoPanel");
		var d = Ext.getCmp(b);
		f.setVisible(!(Ext.isDefined(d.hideInfoPanel) && d.hideInfoPanel));
		e.getLayout().setActiveItem(b);
		this.onStepChange()
	},
	onNextStep: function() {
		var c = Ext.getCmp("stepspanel"),
			d = c.getLayout().getActiveItem(),
			a = true;
		var b = d.query("field:invalid");
		if (b.length > 0) {
			return
		}
		c.up("window").getEl().mask("Loading...");
		if (Ext.isDefined(d.beforeNextStep)) {
			a = d.beforeNextStep(releaseWizardModel)
		}
		if (a != false) {
			this.goToNextStep(d)
		}
	},
	goToNextStep: function(c) {
		var e = Ext.getCmp("stepspanel"),
			b = c ? e.items.indexOfKey(c.id) + 1 : 0,
			a = "";
		for (; b < e.items.getCount(); b++) {
			var d = e.items.items[b];
			if (!Ext.isDefined(d.evaluate) || d.evaluate(releaseWizardModel)) {
				a = d;
				break
			}
		}
		if (!Ext.isEmpty(a)) {
			if (Ext.isDefined(a.prepare)) {
				a.prepare(releaseWizardModel)
			}
			var f = Ext.getCmp("soInfoPanel");
			f.setVisible(!(Ext.isDefined(a.hideInfoPanel) && a.hideInfoPanel));
			if (c) {
				previousStack.push(c.id)
			}
			e.getLayout().setActiveItem(a.id);
			this.onStepChange();
			if (Ext.isDefined(a.afterPrepare)) {
				a.afterPrepare(releaseWizardModel)
			}
			if (typeof(a.controlMask) == "undefined" || a.controlMask == false) {
				e.up("window").getEl().unmask()
			}
		}
	},
	onStepChange: function() {
		var f = Ext.getCmp("stepspanel"),
			g = f.items.indexOfKey(f.getLayout().getActiveItem().id),
			j = false,
			b = f.getLayout().getActiveItem();
		if (b.controlWizardFlowBtn == true) {
			return
		}
		for (var i = g + 1; i < f.items.getCount(); i++) {
			var d = f.items.items[i];
			if (!Ext.isDefined(d.evaluate) || d.evaluate(releaseWizardModel)) {
				j = true;
				break
			}
		}
		var a = Ext.getCmp("releasePreviousBtn"),
			c = Ext.getCmp("releaseNextBtn"),
			e = Ext.getCmp("releaseFinishBtn"),
			h = Ext.getCmp("releaseCancelBtn");
		a.setDisabled(g == 0 || b.disablePrevious);
		e.setDisabled(j);
		c.setDisabled(!j);
		h.setDisabled(b.disableCancel)
	},
	releasetTypeCondition: function() {
		return releaseWizardModel.get("createSerial") && !releaseWizardModel.get("invalidRelease") && !releaseWizardModel.get("batchRelease") && !releaseWizardModel.get("createSkeleton") && releaseWizardModel.isPartialRelease()
	},
	changeAlgStartingTypeRB: function(e, d, b, c) {
		if (d) {
			var a = Ext.getCmp("algStartingSerialNumber");
			if (e.id == "algStartingTypeMax") {
				a.setValue(releaseWizardModel.get("byAlgorithmStartSerialNumberMax"))
			} else {
				if (e.id == "algStartingTypeLatest") {
					a.setValue(releaseWizardModel.get("byAlgorithmStartSerialNumberLatest"))
				}
			}
		}
	},
	changePartStartingTypeRB: function(e, d, a, b) {
		if (d) {
			var c = Ext.getCmp("partStartingSerialNumber");
			if (e.id == "partStartingTypeMax") {
				c.setValue(releaseWizardModel.get("byPartStartSerialNumberMax"))
			} else {
				if (e.id == "partStartingTypeLatest") {
					c.setValue(releaseWizardModel.get("byPartStartSerialNumberLatest"))
				}
			}
		}
	},
	changeReleaseTypeRB: function(f, e, b, c) {
		if (e) {
			var d = Ext.getCmp("algorithmRTPanel");
			var a = Ext.getCmp("partNumberRTPanel");
			d.setDisabled(true);
			a.setDisabled(true);
			if (f.id == "algorithmRT") {
				d.setDisabled(false);
				if (releaseWizardModel.get("isInitiallyPartBased")) {
					Ext.CustomMessageBox.msg("releasewindow", bundle.getMsg("socontrol.message.information"), bundle.getMsg("socontrol.release.wizard.releaseTypeStep.warningMessage"), 9000)
				}
			} else {
				if (f.id == "partNumberRT") {
					a.setDisabled(false)
				}
			}
		}
	},
	changeFullPartialReleaseTypeRB: function(e, d, a, b) {
		if (d) {
			var c = Ext.getCmp("quantityPartialReleaseType");
			if (e.id == "fullReleaseType") {
				c.setDisabled(true)
			} else {
				if (e.id == "partialReleaseType") {
					c.setDisabled(false)
				}
			}
		}
	},
	changePrintTravelerOptionsCB: function(f, e, b, c) {
		var d = Ext.get("printTravelerMessageField-body");
		var a = "";
		if (!e) {
			a = "<img src='" + path + "resources/images/12X12/warning.png'/> Serial Numbers will be released at status 10. USL will be ignored."
		}
		d.dom.innerHTML = a;
		Ext.getCmp("printTravelerMessageField").doLayout()
	},
	changeSerialRulesCB: function(a, k, m, b) {
		if (a.isDisabled()) {
			return
		}
		if (a.id == "showRevisionStep") {
			return
		}
		var c = Ext.getCmp("defineUsl"),
			f = typeof c != "undefined" ? c.isDisabled() : false,
			d = f,
			t = typeof c != "undefined" ? c.getValue() : false,
			p = Ext.getCmp("defineSalesOrder"),
			h = typeof p != "undefined" ? p.isDisabled() : false,
			e = h,
			r = typeof p != "undefined" ? p.getValue() : false,
			g = Ext.getCmp("createSkeleton"),
			o = typeof g != "undefined" ? g.isDisabled() : false,
			q = o,
			s = typeof g != "undefined" ? g.getValue() : false,
			l = Ext.getCmp("nonSerializedBath"),
			j = typeof l != "undefined" ? l.isDisabled() : false,
			i = j,
			n = typeof l != "undefined" ? l.getValue() : false,
			f = s || n;
		h = releaseWizardModel.get("shopOrder").get("boardsPerPanel") > 1 || (s || n);
		o = r || t || n;
		j = r || t || s;
		if (k) {
			t = a != c && d != f ? false : t;
			r = a != p && e != h ? false : r;
			s = a != g && q != o ? false : s;
			n = a != l && i != j ? false : n
		}
		this.updateFieldProperties(c, f, t);
		this.updateFieldProperties(p, h, r);
		this.updateFieldProperties(g, o, s);
		this.updateFieldProperties(l, j, n)
	},
	updateFieldProperties: function(c, a, b) {
		if (typeof c != "undefined") {
			c.setDisabled(a);
			c.setValue(b)
		}
	},
	failureHandler: function(b, a) {
		var f = Ext.decode(b.responseText);
		if (f.messageAttributes != 0) {
			var e = 0,
				d = "",
				g = new Array();
			for (var c in f.messageAttributes) {
				if (c == "message") {
					d = f.messageAttributes[c]
				} else {
					g[e] = f.messageAttributes[c];
					e++
				}
			}
			Ext.CustomMessageBox.msg(a, bundle.getMsg("socontrol.message.error"), Ext.String.format(bundle.getMsg(d), g))
		}
	},
	statics: {
		showLinkage: function() {
			if (releaseWizardModel.data.soLinkage) {
				Ext.widget("shoporderselectionwindow", {
					panelQuantity: releaseWizardModel.get("shopOrder").get("quantity"),
					fromKey: releaseWizardModel.get("shopOrder").get("id")
				}).show();
				var a = Ext.getStore("ShopOrderSelectionStore");
				a.proxy.extraParams.shopOrderNumber = "";
				a.proxy.extraParams.partNumber = "";
				a.proxy.extraParams.fromKey = releaseWizardModel.get("shopOrder").get("id");
				a.proxy.extraParams.panelQuantity = releaseWizardModel.get("shopOrder").get("quantity");
				a.proxy.extraParams.method = "getShopOrdersToLink";
				a.load();
				var b = Ext.getCmp("soselectiongrid");
				b.reconfigure(a)
			}
		},
		printTravelerRelease: function() {
			var e = Ext.getCmp("printTravelerOnePerUnit") ? Ext.getCmp("printTravelerOnePerUnit").getValue() : false;
			var d = Ext.getCmp("printTravelerWip") ? Ext.getCmp("printTravelerWip").getValue() : false;
			var b = Ext.getCmp("printTravelerOnePerOrder") ? Ext.getCmp("printTravelerOnePerOrder").getValue() : false;
			releaseWizardModel.get("shopOrder").set("ATOShopOrderNumber", releaseWizardModel.get("ATOShopOrderNumber"));
			releaseWizardModel.get("shopOrder").set("ATOShopOrderNumber", releaseWizardModel.get("ATOShopOrderNumber"));
			var c = "releasewindow";
			var g = null;
			var a = "";
			if (releaseWizardModel.get("printCurrentSerials")) {
				a = releaseWizardModel.get("startSerialNumber")
			}
			if (b) {
				g = "GenerateReportController.generateOneTravelerPerOrder"
			} else {
				if (e) {
					g = "GenerateReportController.generateWipOrOneTravelerPerUnit";
					releaseWizardModel.get("shopOrder").set("wipTravelerPerUnit", false)
				} else {
					if (d) {
						g = "GenerateReportController.generateWipOrOneTravelerPerUnit";
						releaseWizardModel.get("shopOrder").set("wipTravelerPerUnit", true)
					}
				}
			}
			if (g != null) {
				var f = {
					resourceID: g,
					shopOrder: Ext.JSON.encode(releaseWizardModel.get("shopOrder").data),
					partNumber: releaseWizardModel.get("shopOrder").getPartNumber().get("partNumber"),
					partNumberDescription: releaseWizardModel.get("shopOrder").getPartNumber().get("description"),
					startSerialNumber: a,
					isReprint: false,
					isRelease: true,
					portletVersion: typeof(portletVersion) != "undefined" ? portletVersion : "1.0.0"
				};
				getResourceFile(f, c, null)
			}
		}
	}
});
var portletVersion = "2.5.1.170224-1";
var path = window.windowSOContext.contextPath + "/";
Ext.Loader.setConfig({
	requires: ["SO.view.CustomViewport", "SO.i18n.Bundle"],
	enabled: true,
	paths: {
		"SO.i18n": path + "app/i18n",
		"SO.Custom": path + "app/custom",
		Common: path + "common",
		"SO.ux": path + "app/ux"
	}
});
var lang = Liferay.ThemeDisplay.getLanguageId();
var bundle;
Ext.override(Ext.view.AbstractView, {
	onRender: function() {
		var a = this;
		this.callOverridden();
		if (a.mask && Ext.isObject(a.store)) {
			a.setMaskBind(a.store)
		}
	}
});
Ext.override(Ext.grid.View, {
	enableTextSelection: true
});
Ext.override(Ext.view.Table, {
	enableTextSelection: true
});
Ext.override(Ext.AbstractComponent, {
	listeners: {
		beforeitemmousedown: function(h, b, g, c, j, f) {
			if (typeof(h.plugins) != "undefined") {
				var a = h.plugins;
				for (var d = 0; d < a.length; d++) {
					if (a[d].ptype.toLowerCase() == "gridviewdragdrop") {
						if (j.ctrlKey) {
							a[d].disable()
						} else {
							a[d].enable()
						}
					}
				}
			}
		}
	}
});
var reportJSError = function(d, c, b) {
		var a = Ext.getCmp("somainwindow").zIndexManager.front.id;
		Ext.Ajax.request({
			type: "ajax",
			url: window.windowSOContext.ajaxURL,
			method: "POST",
			async: true,
			format: "json",
			scope: this,
			params: {
				resourceID: "JavaScriptErrorCommonsController.reportJSError",
				linenumber: b,
				url: c,
				message: d,
				screen: a
			}
		});
		if (document.location.hostname == "localhost") {
			Ext.CustomMessageBox.msg(a, "JAVA SCRIPT ERROR", d)
		}
		return false
	};
window.onerror = function(c, b, a) {
	return reportJSError(c, b, a)
}, Ext.override(Ext.data.Types, {
	AUTO: {
		sortType: Ext.data.SortTypes.asUCString,
		type: "auto"
	}
});
Ext.override(Ext.form.Basic, {
	isValid: function() {
		var d = this.callParent(arguments),
			a = null,
			c = null;
		if (!d) {
			a = this.getFields();
			for (var b = 0; b < a.length; b++) {
				c = a.items[b];
				if (Ext.isDefined(c.isValid) && !c.isValid()) {
					c.focus();
					break
				}
			}
		}
		return d
	}
});
Ext.override(Ext.form.Checkbox, {
	setBoxLabel: function(b) {
		b = b || "";
		var c = this,
			a = c.boxLabelEl;
		c.boxLabel = b;
		if (c.rendered) {
			a.update(b);
			a.parent().setDisplayed("");
			c.updateLayout()
		}
	}
});
Ext.require("Ext.ZIndexManager", function() {
	Ext.override(Ext.ZIndexManager, {
		_setActiveChild: function(b, a) {
			var c = this.front;
			if (b !== c) {
				if (c && !c.destroying) {
					c.setActive(false, b)
				}
				this.front = b;
				if (b && b != a) {
					if (!(a instanceof Ext.tip.ToolTip)) {
						b.setActive(true);
						if (b.modal) {
							this._showModalMask(b)
						}
					}
				}
			}
		}
	})
});

function addExceptionListener(b, a) {
	addExceptionListenerOnProxy(b.getProxy(), a)
}
function addExceptionListenerOnProxy(b, a) {
	if (b.hasListener("exception")) {
		if (b.hasListeners.exception) {
			delete b.hasListeners.exception
		}
		if (b.events.exception) {
			delete b.events.exception
		}
	}
	b.on({
		exception: function(f, g) {
			Ext.getCmp("xmain").getEl().unmask();
			if (g.aborted) {
				return
			}
			var j = Ext.decode(g.responseText);
			if (!j || i(j)) {
				Ext.CustomMessageBox.msg(a, "Unknown Error Code: " + g.status, g.statusText);
				return
			}
			if (j.isList) {
				var m = 0;
				var h = Ext.create("SO.view.util.ListProgramErrorWindow");
				for (var k in j.messageAttributes) {
					var o = "param" + m;
					var c = "message" + m;
					if (typeof(j.messageAttributes[o]) != "undefined" && typeof(j.messageAttributes[c]) != "undefined") {
						var d = Ext.create("SO.model.ProgramErrorItemModel");
						d.set("status", "Error");
						d.set("message", Ext.String.format(bundle.getMsg(j.messageAttributes[c]), j.messageAttributes[o]));
						Ext.getCmp("errors").getStore().add(d)
					}
					m++
				}
				h.show()
			} else {
				var m = 0;
				var n = "";
				var e = new Array();
				for (var k in j.messageAttributes) {
					if (k == "message") {
						n = j.messageAttributes[k]
					} else {
						e[m] = j.messageAttributes[k];
						m++
					}
				}
				Ext.CustomMessageBox.msg(a, bundle.getMsg("socontrol.message.error"), l(n, e))
			}
			function i(q) {
				for (var p in q) {
					return false
				}
				return true
			}
			function l(q, s) {
				var p, r = bundle.getMsg(q);
				for (p = 0; p < s.length; p++) {
					r = r.replace("{" + p + "}", s[p])
				}
				return r
			}
		}
	})
}
function failureHandler(b, a) {
	var f = Ext.decode(b.responseText);
	if (f.messageAttributes != 0) {
		var e = 0,
			d = "",
			h = new Array();
		for (var c in f.messageAttributes) {
			if (c == "message") {
				d = f.messageAttributes[c]
			} else {
				h[e] = f.messageAttributes[c];
				e++
			}
		}
		var g = Ext.String.format(bundle.getMsg(d), h);
		Ext.CustomMessageBox.msg(a, bundle.getMsg("socontrol.message.error"), g)
	}
}
function cpmMask(b) {
	var a = Ext.getCmp(b);
	if (typeof a == "undefined") {
		b = "somainwindow";
		a = Ext.getCmp(b)
	}
	return a
}
function getResourceFile(d, c, a) {
	var b = this.cpmMask(c);
	b.getEl().mask("Loading...");
	Ext.Ajax.request({
		url: window.windowSOContext.ajaxURL,
		params: d,
		success: function(e) {
			b = this.cpmMask(b.id);
			b.getEl().unmask();
			var f = Ext.decode(e.responseText);
			if (f.failureMessage) {
				Ext.CustomMessageBox.msg(b.id, bundle.getMsg("socontrol.message.information"), f.failureMessage)
			} else {
				if (f.errorMessage) {
					Ext.CustomMessageBox.msg(b.id, bundle.getMsg("socontrol.message.error"), f.errorMessage)
				}
				Ext.getCmp("report").load({
					params: {
						fileName: f.fileName,
						screen: b.id
					}
				});
				if (a != null) {
					a()
				}
			}
		},
		failure: function(e) {
			b = this.cpmMask(b.id);
			b.getEl().unmask()
		}
	})
}
function checkPermissionsByContainer(a) {
	var f = Ext.ComponentQuery.query("button[actionKey], combobox[actionKey], customtriggerfield[actionKey]", a);
	for (var d = 0; d < f.length; d++) {
		if (f[d].xtype == "button") {
			var e = f[d];
			if (e.actionKey != null) {
				if (!checkPermission(e.actionKey)) {
					e.setVisible(false)
				}
			} else {
				continue
			}
		} else {
			if (f[d].xtype == "combobox" || f[d].superclass.xtype == "combobox") {
				var l = f[d];
				var c = 2;
				var b = true;
				while (b) {
					var h = "trigger" + c + "Cls";
					if (h in l) {
						var k = "action" + c + "Key";
						if (!checkPermission(l[k])) {
							l[h] = ""
						}
						c++
					} else {
						b = false
					}
				}
			} else {
				if (f[d].xtype == "customtriggerfield") {
					var g = f[d];
					if (g.actionKey != null) {
						if (!checkPermission(g.actionKey)) {
							g.hideTrigger = true
						}
					} else {
						continue
					}
				}
			}
		}
	}
}
function checkPermission(b) {
	for (var a = 0; a < permissions.length; a++) {
		if (permissions[a] == b) {
			return true
		}
	}
	return false
}
function getDataType(a) {
	if (Ext.isDate(a)) {
		return "date"
	} else {
		if (Ext.isBoolean(a)) {
			return "boolean"
		} else {
			if (Ext.isNumber(a)) {
				if (isInt(a)) {
					return "int"
				} else {
					return "float"
				}
			} else {
				(Ext.isString(a))
			}
		}
	}
	return "string"
}
function isInt(a) {
	return Number(a) === a && a % 1 === 0
}
Ext.JSON.encodeDate = function(a) {
	return Ext.Date.format(a, '"m/d/Y"')
};
Ext.Ajax.timeout = 5000000;
Ext.override(Ext.data.Connection, {
	timeout: 5000000
});
Ext.override(Ext.data.proxy.Ajax, {
	timeout: 5000000
});
Ext.override(Ext.form.action.Action, {
	timeout: 5000
});
var so_application;
Ext.application({
	name: "SO",
	appFolder: path + "app",
	controllers: ["ShopOrderController", "ShopOrderBrowserController", "RecipeDisplayController", "SerialNumberMaintenanceController", "SerialNumberAssignmentController", "ShopOrderReleaseController", "SalesOrderController", "ReleaseWizardController"],
	autoCreateViewport: false,
	launch: function() {
		so_application = this;
		bundle = Ext.create("SO.i18n.Bundle", {
			bundle: "resourcebundle",
			lang: lang,
			path: path + "resources/bundles",
			noCache: typeof(portletVersion) != "undefined" && portletVersion != "" ? false : true,
			autoLoad: false
		});
		bundle.onReady(function() {
			Ext.select("#xviewport").removeCls("loading");
			Ext.create("SO.view.CustomViewport");
			Ext.create("SO.view.SOMainWindow").show();
			Ext.widget("shopordermenu").show()
		});
		bundle.load()
	}
});
Ext.override(Ext.form.ComboBox, {
	constructor: function(a) {
		this.callParent(arguments);
		this.originalFireEvent = this.fireEvent;
		this.fireEvent = function(d, b, c) {
			this.lastEventFired = d;
			if (d == "select") {
				this.lastSelectedValue = b.getValue()
			}
			this.originalFireEvent.apply(this, arguments)
		}
	},
	findRecordCaseInsensitive: function(field, value) {
		var store = this.store;
		var record = null;
		if (value == "") {
			return false
		}
		if (value === parseInt(value, 10)) {
			var ds = this.store,
				idx = ds.findExact(field, value);
			return idx !== -1 ? ds.getAt(idx) : false
		} else {
			store.data.each(function(rec) {
				var compareValue = eval("rec.data." + field);
				if (compareValue === parseInt(compareValue, 10)) {
					if (value == compareValue) {
						record = rec
					}
				} else {
					if (value.toLowerCase() == compareValue.toLowerCase()) {
						record = rec
					}
				}
			})
		}
		return record == null ? false : record
	},
	assertValue: function() {
		var b = this,
			c = b.getRawValue(),
			d;
		if (b.forceSelection && b.ignoreCustomValueAssertion !== false) {
			if (b.multiSelect) {
				if (c !== b.getDisplayValue()) {
					b.setValue(b.lastSelection)
				}
			} else {
				d = b.findRecordCaseInsensitive(b.displayField, c);
				if (d) {
					var a = d.get(b.valueField) != b.getValue() || (d.get(b.valueField) != b.lastSelectedValue);
					b.select(d);
					if (a) {
						b.fireEvent("select", b, [d])
					}
				} else {
					b.setValue(b.lastSelection)
				}
			}
		}
		b.collapse()
	}
});
Ext.define("SO.ux.form.MultiSelect", {
	extend: Ext.form.FieldContainer,
	mixins: {
		bindable: Ext.util.Bindable,
		field: Ext.form.field.Field
	},
	alias: ["widget.multiselectfield", "widget.multiselect"],
	ddReorder: false,
	appendOnly: false,
	displayField: "text",
	allowBlank: true,
	minSelections: 0,
	maxSelections: Number.MAX_VALUE,
	blankText: "This field is required",
	minSelectionsText: "Minimum {0} item(s) required",
	maxSelectionsText: "Minimum {0} item(s) required",
	delimiter: ",",
	ignoreSelectChange: 0,
	initComponent: function() {
		var a = this;
		a.bindStore(a.store, true);
		if (a.store.autoCreated) {
			a.valueField = a.displayField = "field1";
			if (!a.store.expanded) {
				a.displayField = "field2"
			}
		}
		if (!Ext.isDefined(a.valueField)) {
			a.valueField = a.displayField
		}
		Ext.apply(a, a.setupItems());
		a.callParent();
		a.initField();
		a.addEvents("drop")
	},
	setupItems: function() {
		var a = this;
		a.boundList = Ext.create("Ext.view.BoundList", {
			deferInitialRefresh: false,
			multiSelect: true,
			store: a.store,
			displayField: a.displayField,
			disabled: a.disabled
		});
		a.boundList.getSelectionModel().on("selectionchange", a.onSelectChange, a);
		return {
			layout: "fit",
			title: a.title,
			tbar: a.tbar,
			items: a.boundList
		}
	},
	onSelectChange: function(a, b) {
		if (!this.ignoreSelectChange) {
			this.setValue(b)
		}
	},
	getSelected: function() {
		return this.boundList.getSelectionModel().getSelection()
	},
	isEqual: function(e, d) {
		var b = Ext.Array.from,
			c = 0,
			a;
		e = b(e);
		d = b(d);
		a = e.length;
		if (a !== d.length) {
			return false
		}
		for (; c < a; c++) {
			if (d[c] !== e[c]) {
				return false
			}
		}
		return true
	},
	afterRender: function() {
		var a = this;
		a.callParent();
		if (a.selectOnRender) {
			++a.ignoreSelectChange;
			a.boundList.getSelectionModel().select(a.getRecordsForValue(a.value));
			--a.ignoreSelectChange;
			delete a.toSelect
		}
		if (a.ddReorder && !a.dragGroup && !a.dropGroup) {
			a.dragGroup = a.dropGroup = "MultiselectDD-" + Ext.id()
		}
		if (a.draggable || a.dragGroup) {
			a.dragZone = Ext.create("Ext.view.DragZone", {
				view: a.boundList,
				ddGroup: a.dragGroup,
				dragText: "{0} Item{1}"
			})
		}
		if (a.droppable || a.dropGroup) {
			a.dropZone = Ext.create("Ext.view.DropZone", {
				view: a.boundList,
				ddGroup: a.dropGroup,
				handleNodeDrop: function(h, g, b) {
					var c = this.view,
						e = c.getStore(),
						d = h.records,
						f;
					h.view.store.remove(d);
					f = e.indexOf(g);
					if (b === "after") {
						f++
					}
					e.insert(f, d);
					c.getSelectionModel().select(d);
					a.fireEvent("drop", a, d)
				}
			})
		}
	},
	isValid: function() {
		var b = this,
			a = b.disabled,
			c = b.forceValidation || !a;
		return c ? b.validateValue(b.value) : a
	},
	validateValue: function(b) {
		var a = this,
			d = a.getErrors(b),
			c = Ext.isEmpty(d);
		if (!a.preventMark) {
			if (c) {
				a.clearInvalid()
			} else {
				a.markInvalid(d)
			}
		}
		return c
	},
	markInvalid: function(c) {
		var b = this,
			a = b.getActiveError();
		b.setActiveErrors(Ext.Array.from(c));
		if (a !== b.getActiveError()) {
			b.updateLayout()
		}
	},
	clearInvalid: function() {
		var b = this,
			a = b.hasActiveError();
		b.unsetActiveError();
		if (a) {
			b.updateLayout()
		}
	},
	getSubmitData: function() {
		var a = this,
			b = null,
			c;
		if (!a.disabled && a.submitValue && !a.isFileUpload()) {
			c = a.getSubmitValue();
			if (c !== null) {
				b = {};
				b[a.getName()] = c
			}
		}
		return b
	},
	getSubmitValue: function() {
		var b = this,
			a = b.delimiter,
			c = b.getValue();
		return Ext.isString(a) ? c.join(a) : c
	},
	getValue: function() {
		return this.value
	},
	getRecordsForValue: function(g) {
		var f = this,
			a = [],
			h = f.store.getRange(),
			l = f.valueField,
			d = 0,
			k = h.length,
			b, c, e;
		for (e = g.length; d < e; ++d) {
			for (c = 0; c < k; ++c) {
				b = h[c];
				if (b.get(l) == g[d]) {
					a.push(b)
				}
			}
		}
		return a
	},
	setupValue: function(g) {
		var b = this.delimiter,
			d = this.valueField,
			e = 0,
			c, a, f;
		if (Ext.isDefined(g)) {
			if (b && Ext.isString(g)) {
				g = g.split(b)
			} else {
				if (!Ext.isArray(g)) {
					g = [g]
				}
			}
			for (a = g.length; e < a; ++e) {
				f = g[e];
				if (f && f.isModel) {
					g[e] = f.get(d)
				}
			}
			c = Ext.Array.unique(g)
		} else {
			c = []
		}
		return c
	},
	setValue: function(c) {
		var b = this,
			a = b.boundList.getSelectionModel();
		if (!b.store.getCount()) {
			b.store.on({
				load: Ext.Function.bind(b.setValue, b, [c]),
				single: true
			});
			return
		}
		c = b.setupValue(c);
		b.mixins.field.setValue.call(b, c);
		if (b.rendered) {
			++b.ignoreSelectChange;
			a.deselectAll();
			a.select(b.getRecordsForValue(c));
			--b.ignoreSelectChange
		} else {
			b.selectOnRender = true
		}
	},
	clearValue: function() {
		this.setValue([])
	},
	onEnable: function() {
		var a = this.boundList;
		this.callParent();
		if (a) {
			a.enable()
		}
	},
	onDisable: function() {
		var a = this.boundList;
		this.callParent();
		if (a) {
			a.disable()
		}
	},
	getErrors: function(b) {
		var a = this,
			c = Ext.String.format,
			e = [],
			d;
		b = Ext.Array.from(b || a.getValue());
		d = b.length;
		if (!a.allowBlank && d < 1) {
			e.push(a.blankText)
		}
		if (d < a.minSelections) {
			e.push(c(a.minSelectionsText, a.minSelections))
		}
		if (d > a.maxSelections) {
			e.push(c(a.maxSelectionsText, a.maxSelections))
		}
		return e
	},
	onDestroy: function() {
		var a = this;
		a.bindStore(null);
		Ext.destroy(a.dragZone, a.dropZone);
		a.callParent()
	},
	onBindStore: function(a) {
		var b = this.boundList;
		if (b) {
			b.bindStore(a)
		}
	}
});
Ext.define("SO.ux.form.ItemSelector", {
	extend: SO.ux.form.MultiSelect,
	alias: ["widget.itemselectorfield", "widget.itemselector"],
	hideNavIcons: false,
	buttons: ["top", "up", "addAll", "add", "removeAll", "remove", "down", "bottom"],
	buttonsText: {
		top: "Move to Top",
		up: "Move Up",
		addAll: "Add All to Selected",
		add: "Add to Selected",
		removeAll: "Remove All From Selected",
		remove: "Remove from Selected",
		down: "Move Down",
		bottom: "Move to Bottom"
	},
	initComponent: function() {
		var a = this;
		a.ddGroup = a.id + "-dd";
		a.callParent();
		a.bindStore(a.store)
	},
	createList: function() {
		var a = this;
		return Ext.create("SO.ux.form.MultiSelect", {
			submitValue: false,
			flex: 1,
			dragGroup: a.ddGroup,
			dropGroup: a.ddGroup,
			store: {
				model: a.store.model,
				data: []
			},
			displayField: a.displayField,
			disabled: a.disabled,
			listeners: {
				boundList: {
					scope: a,
					itemdblclick: a.onItemDblClick,
					drop: a.syncValue
				}
			}
		})
	},
	setupItems: function() {
		var a = this;
		a.fromField = a.createList();
		a.toField = a.createList();
		return {
			layout: {
				type: "hbox",
				align: "stretch"
			},
			items: [a.fromField,
			{
				xtype: "container",
				margins: "0 5",
				width: 30,
				layout: {
					type: "vbox",
					pack: "center"
				},
				items: a.createButtons()
			},
			a.toField]
		}
	},
	createButtons: function() {
		var b = this,
			a = [];
		if (!b.hideNavIcons) {
			Ext.Array.forEach(b.buttons, function(c) {
				a.push({
					xtype: "button",
					tooltip: b.buttonsText[c],
					handler: b["on" + Ext.String.capitalize(c) + "BtnClick"],
					align: "top",
					cls: "",
					iconCls: "x-form-itemselector-" + c,
					navBtn: true,
					scope: b,
					margin: "0 0 4 0",
					style: {
						"min-width": "30px"
					},
					width: 30
				})
			})
		}
		return a
	},
	getSelections: function(c) {
		var a = c.getStore(),
			b = c.getSelectionModel().getSelection();
		return Ext.Array.sort(b, function(e, d) {
			e = a.indexOf(e);
			d = a.indexOf(d);
			if (e < d) {
				return -1
			} else {
				if (e > d) {
					return 1
				}
			}
			return 0
		})
	},
	onTopBtnClick: function() {
		var c = this.toField.boundList,
			a = c.getStore(),
			b = this.getSelections(c);
		a.suspendEvents();
		a.remove(b, true);
		a.insert(0, b);
		a.resumeEvents();
		c.refresh();
		this.syncValue();
		c.getSelectionModel().select(b)
	},
	onBottomBtnClick: function() {
		var c = this.toField.boundList,
			a = c.getStore(),
			b = this.getSelections(c);
		a.suspendEvents();
		a.remove(b, true);
		a.add(b);
		a.resumeEvents();
		c.refresh();
		this.syncValue();
		c.getSelectionModel().select(b)
	},
	onUpBtnClick: function() {
		var f = this.toField.boundList,
			b = f.getStore(),
			e = this.getSelections(f),
			d = 0,
			a = e.length,
			c = b.getCount();
		for (; d < a; ++d) {
			c = Math.min(c, b.indexOf(e[d]))
		}
		if (c > 0) {
			b.suspendEvents();
			b.remove(e, true);
			b.insert(c - 1, e);
			b.resumeEvents();
			f.refresh();
			this.syncValue();
			f.getSelectionModel().select(e)
		}
	},
	onDownBtnClick: function() {
		var f = this.toField.boundList,
			b = f.getStore(),
			e = this.getSelections(f),
			d = 0,
			a = e.length,
			c = 0;
		for (; d < a; ++d) {
			c = Math.max(c, b.indexOf(e[d]))
		}
		if (c < b.getCount() - 1) {
			b.suspendEvents();
			b.remove(e, true);
			b.insert(c + 2 - a, e);
			b.resumeEvents();
			f.refresh();
			this.syncValue();
			f.getSelectionModel().select(e)
		}
	},
	onAddBtnClick: function() {
		var b = this,
			c = b.fromField.boundList,
			a = this.getSelections(c);
		c.getStore().remove(a);
		this.toField.boundList.getStore().add(a);
		this.syncValue()
	},
	onAddAllBtnClick: function() {
		var d = this,
			b = d.fromField.boundList.getStore(),
			c = this.toField.boundList;
		toStore = c.getStore();
		for (var a = b.getRange().length - 1; a >= 0; a--) {
			var e = b.getRange()[a];
			toStore.add(e);
			b.remove(e);
			value = d.setupValue(value);
			d.mixins.field.setValue.call(d, value);
			c.getSelectionModel().select(e);
			d.onTopBtnClick()
		}
	},
	onRemoveBtnClick: function() {
		var c = this,
			b = c.toField.boundList,
			a = this.getSelections(b);
		b.getStore().remove(a);
		this.fromField.boundList.getStore().add(a);
		this.syncValue()
	},
	onRemoveAllBtnClick: function() {
		var b = this,
			a = b.fromField.boundList.getStore(),
			c = this.toField.boundList.getStore();
		a.loadData(c.getRange(), true);
		c.removeAll();
		this.syncValue()
	},
	syncValue: function() {
		this.setValue(this.toField.store.getRange())
	},
	onItemDblClick: function(b, e) {
		var c = this,
			g = c.fromField.store,
			f = c.toField.store,
			d, a;
		if (b === c.fromField.boundList) {
			d = g;
			a = f
		} else {
			d = f;
			a = g
		}
		d.remove(e);
		a.add(e);
		if (b === c.fromField.boundList) {
			c.mixins.field.setValue.call(c, e)
		}
		c.syncValue()
	},
	setValue: function(e) {
		var c = this,
			a = c.fromField.store,
			d = c.toField.store,
			b;
		if (!c.fromField.store.getCount()) {
			c.fromField.store.on({
				load: Ext.Function.bind(c.setValue, c, [e]),
				single: true
			});
			return
		}
		e = c.setupValue(e);
		c.mixins.field.setValue.call(c, e);
		b = c.getRecordsForValue(e);
		Ext.Array.forEach(d.getRange(), function(f) {
			if (!Ext.Array.contains(b, f)) {
				d.remove(f);
				a.add(f)
			}
		});
		d.removeAll();
		Ext.Array.forEach(b, function(f) {
			if (a.indexOf(f) > -1) {
				a.remove(f)
			}
			d.add(f)
		})
	},
	onBindStore: function(a, b) {
		var c = this;
		if (c.fromField) {
			c.fromField.store.removeAll();
			c.toField.store.removeAll();
			if (a.getCount()) {
				c.populateFromStore(a)
			} else {
				c.store.on("load", c.populateFromStore, c)
			}
		}
	},
	populateFromStore: function(a) {
		this.fromField.store.add(a.getRange());
		this.fromField.store.fireEvent("load", this.fromField.store)
	},
	onEnable: function() {
		var a = this;
		a.callParent();
		a.fromField.enable();
		a.toField.enable();
		Ext.Array.forEach(a.query("[navBtn]"), function(b) {
			b.enable()
		})
	},
	onDisable: function() {
		var a = this;
		a.callParent();
		a.fromField.disable();
		a.toField.disable();
		Ext.Array.forEach(a.query("[navBtn]"), function(b) {
			b.disable()
		})
	},
	onDestroy: function() {
		this.bindStore(null);
		this.callParent()
	}
});
Ext.define("SO.custom.ConfigureExportWindow", {
	extend: Ext.window.Window,
	alias: "widget.configureexportwindow",
	width: 679,
	height: 485,
	id: "configureexportwindow",
	recordToTitle: null,
	closable: false,
	resizable: false,
	modelToLoad: null,
	availFields: null,
	model: true,
	constrain: true,
	renderTo: "xmain",
	beanName: null,
	resourceID: null,
	store: null,
	gridTitle: null,
	initComponent: function(b) {
		var a = this;
		a.items = a.buildPanel();
		a.border = 0;
		a.modal = true;
		a.layout = "fit";
		a.title = bundle.getMsg("Export Configuration");
		this.callParent(b)
	},
	buildPanel: function() {
		var a = this;
		var b = new Ext.data.ArrayStore({
			fields: ["dataIndex", "text", "dataType"]
		});
		b.add(a.availFields);
		var c = Ext.create("Ext.form.Panel", {
			bodyPadding: 10,
			border: 0,
			layout: "fit",
			autoHeight: true,
			id: "fieldSelectorForm",
			autoWidth: true,
			items: [{
				xtype: "itemselector",
				name: "itemselector",
				id: "itemselector-field",
				anchor: "80%",
				fieldLabel: "Fields",
				labelWidth: 50,
				store: b,
				displayField: "text",
				valueField: "text",
				allowBlank: false,
				msgTarget: "side"
			}],
			dockedItems: [{
				xtype: "toolbar",
				dock: "top",
				id: "exportTypeConfigToolBar",
				cls: "transparentBackground",
				baseCls: "transparentBackground",
				bodyCls: "transparentBackground",
				border: 0,
				items: [{
					xtype: "combobox",
					fieldLabel: bundle.getMsg("Type"),
					labelAlign: "left",
					labelWidth: 50,
					name: "exportType",
					id: "exportType",
					valueField: "exportType",
					displayField: "exportType",
					margin: "10 20 20 10",
					allowAll: false,
					allowBlank: false,
					forceSelection: true,
					width: 300,
					editable: true,
					value: "",
					store: new Ext.data.ArrayStore({
						fields: ["exportType"],
						data: [
							["CSV"],
							["HTML"],
							["PDF"],
							["XLS"]
						]
					})
				}, {
					xtype: "combobox",
					fieldLabel: bundle.getMsg("Page Orientation"),
					labelAlign: "left",
					labelWidth: 70,
					name: "isPortrait",
					id: "isPortrait",
					valueField: "isPortrait",
					displayField: "orienationPage",
					margin: "10 0 20 10",
					allowAll: false,
					allowBlank: false,
					forceSelection: true,
					width: 300,
					editable: true,
					value: true,
					store: new Ext.data.ArrayStore({
						fields: ["isPortrait", "orienationPage"],
						data: [
							[true, "Portrait"],
							[false, "Landscape"]
						]
					})
				}]
			}],
			bbar: ["->",
			{
				xtype: "button",
				text: bundle.getMsg("button.export"),
				handler: function(e) {
					var f = this;
					exportWindow = Ext.getCmp("configureexportwindow"), exportType = Ext.getCmp("exportType"), selectedStore = Ext.getCmp("itemselector-field").items.items[2].store;
					if (exportWindow.items.items[0].getForm().isValid()) {
						var d = function() {
								exportWindow.close()
							};
						var g = {
							resourceID: exportWindow.resourceID,
							listResourceID: exportWindow.store.proxy.extraParams.resourceID,
							filterModel: exportWindow.store.proxy.extraParams.filterModel,
							type: exportType.getValue(),
							beanName: exportWindow.beanName,
							title: exportWindow.gridTitle,
							allFields: false,
							fieldsToAdd: Ext.encode(Ext.Array.pluck(selectedStore.data.items, "data")),
							isPortrait: Ext.getCmp("isPortrait").getValue(),
							limit: -1
						};
						Object.getOwnPropertyNames(exportWindow.store.proxy.extraParams).forEach(function(i, h, j) {
							if (i != "resourceID" && i != "filterModel" && i != "offset") {
								g[i] = exportWindow.store.proxy.extraParams[i]
							}
						});
						getResourceFile(g, "configureexportwindow", d)
					}
				}
			}, {
				xtype: "button",
				text: bundle.getMsg("button.cancel"),
				action: "onCancel",
				handler: function(d) {
					d.up("window").close()
				}
			}]
		});
		return c
	}
});
Ext.CustomMessageBox = function() {
	var b;

	function a(c, d) {
		return '<div class="msg"><h3>' + c + "</h3><p>" + d + "</p></div>"
	}
	return {
		msg: function(e, j, i, h) {
			var d = e + "msg-div";
			if (Ext.fly(e).getById(d) == null) {
				b = false
			} else {
				b = Ext.get(d)
			}
			if (!b) {
				var g = '<div id="' + d + '" class="msg-div"></div>';
				b = Ext.DomHelper.insertFirst(e, g, true)
			}
			var f = Ext.String.format.apply(String, Array.prototype.slice.call(arguments, 2));
			var c = Ext.DomHelper.append(b, a(j, f), true);
			c.hide();
			if (!h) {
				h = 3000
			}
			c.slideIn("t").ghost("t", {
				delay: h,
				remove: true
			})
		}
	}
}();
Ext.define("SO.i18n.reader.Property", {
	extend: Ext.data.reader.Json,
	alias: "reader.property",
	constructor: function(a) {
		a = a || {};
		Ext.applyIf(a, {
			idProperty: "key",
			successProperty: "success",
			totalProperty: "total"
		});
		this.callParent([a])
	},
	getResponseData: function(a) {
		return this.readRecords(a)
	},
	getData: function(d) {
		var b = [],
			g, j, h = this.readLines(d),
			c = h.length;
		for (var e = 0; e < c; e++) {
			var a = h[e].search(/[\s:=]/);
			var k = this.clearValueExtraChars(h[e].substring(a + 1));
			k = k.replace(/^\s+|\s+$/g, "");
			g = {
				value: k,
				key: this.clearKeyExtraChars(h[e].substring(0, a))
			};
			b[e] = g
		}
		return b
	},
	clearKeyExtraChars: function(a) {
		return (a ? a.replace(/[:=]/gi, "") : "")
	},
	clearValueExtraChars: function(a) {
		return (a ? a.replace(/^\s*[:|=]/gi, "") : "")
	},
	readLines: function(b) {
		var a = b.responseText;
		return (a ? a.match(/.*(.*\\\s*\n)+.*|^((?!^\s*[#!]).).*$/gim) : [])
	}
});
Ext.define("SO.i18n.model.Property", {
	extend: Ext.data.Model,
	idProperty: "key",
	fields: ["key", "value"]
});
Ext.define("SO.i18n.Bundle", {
	extend: Ext.data.Store,
	defaultLanguage: "en_US",
	resourceExt: ".properties",
	config: {
		bundle: "message",
		path: "resources"
	},
	constructor: function(c) {
		c = c || {};
		var d = this,
			e = d.formatLanguageCode(c.lang || d.guessLanguage()),
			a = (c.noCache !== false),
			b;
		d.language = e;
		d.bundle = c.bundle || d.bundle;
		d.path = c.path || d.path;
		b = this.buildURL(e);
		delete c.lang;
		delete c.noCache;
		Ext.applyIf(c, {
			autoLoad: true,
			model: "SO.i18n.model.Property",
			proxy: {
				type: "ajax",
				url: b,
				noCache: a,
				reader: {
					type: "property"
				},
				getParams: Ext.emptyFn
			},
			listeners: {
				load: this.onBundleLoad,
				scope: this
			}
		});
		d.callParent([c]);
		d.getProxy().on("exception", this.loadParent, this, {
			single: true
		})
	},
	guessLanguage: function() {
		return (navigator.language || navigator.browserLanguage || navigator.userLanguage || this.defaultLanguage)
	},
	getMsg: function(a) {
		var b = this.getById(a);
		value = b ? this.convertjEsc2Char(b.get("value"), true) : a;
		return value
	},
	convertjEsc2Char: function(b, c) {
		var a = this;
		b = b.replace(/\\U([A-Fa-f0-9]{8})/g, function(d, e) {
			return a.hex2char(e)
		});
		b = b.replace(/\\u([A-Fa-f0-9]{4})/g, function(d, e) {
			return a.hex2char(e)
		});
		if (c) {
			b = b.replace(/\\b/g, "\b");
			b = b.replace(/\\t/g, "\t");
			b = b.replace(/\\n/g, "\n");
			b = b.replace(/\\v/g, "\v");
			b = b.replace(/\\f/g, "\f");
			b = b.replace(/\\r/g, "\r");
			b = b.replace(/\\\'/g, "'");
			b = b.replace(/\\\"/g, '"');
			b = b.replace(/\\\\/g, "\\");
			b = b.replace(/\\r\\n/gi, "<BR>");
			b = b.replace(/\\n/gi, "<BR>")
		}
		return b
	},
	hex2char: function(b) {
		var a = "";
		var c = parseInt(b, 16);
		if (c <= 65535) {
			a += String.fromCharCode(c)
		} else {
			if (c <= 1114111) {
				c -= 65536;
				a += String.fromCharCode(55296 | (c >> 10)) + String.fromCharCode(56320 | (c & 1023))
			} else {
				a += "hex2Char error: Code point out of range: " + this.dec2hex(c)
			}
		}
		return a
	},
	dec2hex: function(a) {
		return (a + 0).toString(16).toUpperCase()
	},
	onReady: function(a) {
		this.readyFn = a;
		this.on("loaded", this.readyFn, this)
	},
	onBundleLoad: function(b, a, c, d) {
		if (c) {
			this.fireEvent("loaded")
		}
	},
	onProxyLoad: function(a) {
		if (a.getRecords()) {
			this.callParent(arguments)
		}
	},
	buildURL: function(b) {
		var a = "";
		if (this.path) {
			a += this.path + "/"
		}
		a += this.bundle;
		if (b) {
			a += "_" + b
		}
		if (typeof(portletVersion) != "undefined" && portletVersion != "") {
			a += "_" + portletVersion
		}
		a += this.resourceExt;
		return a
	},
	loadParent: function() {
		this.getProxy().url = this.buildURL(this.formatLanguageCode(this.defaultLanguage));
		this.load()
	},
	formatLanguageCode: function(b) {
		var a = b.split("_");
		a[0] = (a[0]) ? a[0].toLowerCase() : "";
		a[1] = (a[1]) ? a[1].toUpperCase() : "";
		return a.join("_")
	}
});
Ext.define("SO.model.ProgramErrorItemModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "status"
	}, {
		name: "message"
	}]
});
Ext.define("SO.model.RefDesignatorModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "bomPkId",
		type: "int"
	}, {
		name: "bomItemPkId",
		type: "int"
	}, {
		name: "refDesignator",
		type: "string"
	}, {
		name: "description",
		type: "string"
	}, {
		name: "idx",
		type: "int"
	}, {
		name: "step",
		type: "int"
	}, {
		name: "refDesKey",
		type: "int"
	}, {
		name: "refDesignatorPkId",
		type: "int"
	}]
});
Ext.define("SO.model.SalesOrderFilterModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "salesOrder"
	}, {
		name: "isFull"
	}]
});
Ext.define("SO.model.ShopOrderBomModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "shopOrderKey"
	}, {
		name: "shopOrderNumber"
	}, {
		name: "partKey"
	}, {
		name: "partNumber"
	}, {
		name: "bomPkId"
	}, {
		name: "bomNumber"
	}],
	idProperty: "bomPkId",
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	},
	hasMany: [{
		model: "SO.model.BomItemModel",
		name: "bomitems"
	}]
});
Ext.define("SO.model.ShopOrderToLink", {
	extend: Ext.data.Model,
	fields: [{
		name: "id"
	}, {
		name: "shopOrderNumber"
	}, {
		name: "partKey",
		defaultValue: 0
	}, {
		name: "partNumber"
	}, {
		name: "quantity",
		defaultValue: 0
	}]
});
Ext.define("SO.store.ProgramErrorItemStore", {
	extend: Ext.data.Store,
	model: "SO.model.ProgramErrorItemModel",
	pageSize: 50,
	remoteSort: false,
	autoLoad: false,
	autoSync: false
});
Ext.define("SO.store.RefDesignatorStore", {
	extend: Ext.data.Store,
	model: "SO.model.RefDesignatorModel",
	remoteSort: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			messageProperty: "message",
			totalProperty: "totalCount",
			root: "data"
		})
	}
});
Ext.define("SO.store.ShopOrderBrowserStore", {
	extend: Common.store.PaggingStore,
	model: "SO.model.ShopOrderModel",
	pageSize: 50,
	remoteSort: false,
	autoLoad: false,
	proxy: {
		type: "ajax",
		format: "json",
		url: window.windowSOContext.ajaxURL,
		appendId: false,
		extraParams: {
			resourceID: "ShopOrderController.getShopOrderBrowser"
		},
		reader: Ext.create("Ext.data.JsonReader", {
			successProperty: "success",
			idProperty: "id",
			totalProperty: "totalCount",
			root: "data"
		}),
		writer: Ext.create("Ext.data.JsonWriter", {
			encode: false,
			writeAllFields: true,
			root: "data"
		})
	}
});
Ext.define("SO.ux.PagingStore", {
	extend: Ext.data.Store,
	alias: "store.pagingstore",
	destroyStore: function() {
		this.callParent(arguments);
		this.allData = null
	},
	isPaging: function(b) {
		var d = this,
			h = b.start,
			a = b.limit,
			f = b.page,
			e;
		if ((typeof h != "number") || (typeof a != "number")) {
			delete d.start;
			delete d.limit;
			delete d.page;
			d.lastParams = b.params;
			return false
		}
		d.start = h;
		d.limit = a;
		d.currentPage = f;
		var c = this.lastParams;
		e = Ext.apply({}, b.params, this.proxy ? this.proxy.extraParams : {});
		d.lastParams = e;
		if (!this.proxy) {
			return true
		}
		if (!c) {
			return false
		}
		for (var g in e) {
			if (e.hasOwnProperty(g) && (e[g] !== c[g])) {
				return false
			}
		}
		for (g in c) {
			if (c.hasOwnProperty(g) && (e[g] !== c[g])) {
				return false
			}
		}
		return true
	},
	applyPaging: function() {
		var h = this,
			b = h.start,
			d = h.limit,
			c, e;
		if ((typeof b == "number") && (typeof d == "number")) {
			c = this.data;
			e = new Ext.util.MixedCollection(c.allowFunctions, c.getKey);
			e.items = c.items.slice(b, b + d);
			e.keys = c.keys.slice(b, b + d);
			var g = e.length = e.items.length;
			var a = {};
			for (var f = 0; f < g; f++) {
				var j = e.items[f];
				a[e.getKey(j)] = j
			}
			e.map = a;
			h.allData = c;
			h.data = e
		}
	},
	loadRecords: function(f, j) {
		var h = this,
			g = 0,
			e = f.length,
			d, a, b = h.snapshot,
			c = h.allData;
		if (j) {
			d = j.start;
			a = j.addRecords
		}
		if (!a) {
			delete h.allData;
			delete h.snapshot;
			h.clearData(true)
		} else {
			if (c) {
				c.addAll(f)
			} else {
				if (b) {
					b.addAll(f)
				}
			}
		}
		h.data.addAll(f);
		if (!h.allData) {
			h.applyPaging()
		}
		if (d !== undefined) {
			for (; g < e; g++) {
				f[g].index = d + g;
				f[g].join(h)
			}
		} else {
			for (; g < e; g++) {
				f[g].join(h)
			}
		}
		h.suspendEvents();
		if (h.filterOnLoad && !h.remoteFilter) {
			h.filter()
		}
		if (h.sortOnLoad && !h.remoteSort) {
			h.sort(undefined, undefined, undefined, true)
		}
		h.resumeEvents();
		h.fireEvent("datachanged", h);
		h.fireEvent("refresh", h)
	},
	loadData: function(h, a) {
		var g = this,
			c = g.model,
			f = h.length,
			e = [],
			d, b;
		g.isPaging(Ext.apply({}, this.lastOptions ? this.lastOptions : {}));
		for (d = 0; d < f; d++) {
			b = h[d];
			if (!(b.isModel)) {
				b = Ext.ModelManager.create(b, c)
			}
			e.push(b)
		}
		g.loadRecords(e, a ? g.addRecordsOptions : undefined)
	},
	loadRawData: function(e, b) {
		var d = this,
			a = d.proxy.reader.read(e),
			c = a.records;
		if (a.success) {
			d.totalCount = a.total;
			d.isPaging(Ext.apply({}, this.lastOptions ? this.lastOptions : {}));
			d.loadRecords(c, b ? d.addRecordsOptions : undefined);
			d.fireEvent("load", d, c, true)
		}
	},
	load: function(b) {
		var d = this,
			c;
		b = b || {};
		if (typeof b == "function") {
			b = {
				callback: b
			}
		}
		b.groupers = b.groupers || d.groupers.items;
		b.page = b.page || d.currentPage;
		b.start = (b.start !== undefined) ? b.start : (b.page - 1) * d.pageSize;
		b.limit = b.limit || d.pageSize;
		b.addRecords = b.addRecords || false;
		if (d.buffered) {
			return d.loadToPrefetch(b)
		}
		var a;
		b = Ext.apply({
			action: "read",
			filters: d.filters.items,
			sorters: d.getSorters()
		}, b);
		d.lastOptions = b;
		a = new Ext.data.Operation(b);
		if (d.fireEvent("beforeload", d, a) !== false) {
			d.loading = true;
			c = Ext.apply({}, b);
			if (d.isPaging(c)) {
				Ext.Function.defer(function() {
					if (d.allData) {
						d.data = d.allData;
						delete d.allData
					}
					d.applyPaging();
					d.fireEvent("datachanged", d);
					d.fireEvent("refresh", d);
					var e = [].concat(d.data.items);
					d.loading = false;
					d.fireEvent("load", d, e, true);
					if (d.hasListeners.read) {
						d.fireEvent("read", d, e, true)
					}
					if (b.callback) {
						b.callback.call(b.scope || d, e, b, true)
					}
				}, 1, d);
				return d
			}
			d.proxy.read(a, d.onProxyLoad, d)
		}
		return d
	},
	insert: function(d, c) {
		var g = this,
			f = false,
			e, b, a;
		c = [].concat(c);
		for (e = 0, a = c.length; e < a; e++) {
			b = g.createModel(c[e]);
			b.set(g.modelDefaults);
			c[e] = b;
			g.data.insert(d + e, b);
			b.join(g);
			f = f || b.phantom === true
		}
		if (g.allData) {
			g.allData.addAll(c)
		}
		if (g.snapshot) {
			g.snapshot.addAll(c)
		}
		if (g.requireSort) {
			g.suspendEvents();
			g.sort();
			g.resumeEvents()
		}
		g.fireEvent("add", g, c, d);
		g.fireEvent("datachanged", g);
		if (g.autoSync && f && !g.autoSyncSuspended) {
			g.sync()
		}
	},
	doSort: function(b) {
		var e = this,
			a, d, c;
		if (e.remoteSort) {
			if (e.buffered) {
				e.pageMap.clear();
				e.loadPage(1)
			} else {
				e.load()
			}
		} else {
			if (e.allData) {
				e.data = e.allData;
				delete e.allData
			}
			e.data.sortBy(b);
			if (!e.buffered) {
				a = e.getRange();
				d = a.length;
				for (c = 0; c < d; c++) {
					a[c].index = c
				}
			}
			e.applyPaging();
			e.fireEvent("datachanged", e);
			e.fireEvent("refresh", e)
		}
	},
	getTotalCount: function() {
		return this.allData ? this.allData.getCount() : this.totalCount || 0
	},
	getNewRecords: function() {
		if (this.allData) {
			return this.allData.filterBy(this.filterNew).items
		}
		return this.data.filterBy(this.filterNew).items
	},
	getUpdatedRecords: function() {
		if (this.allData) {
			return this.allData.filterBy(this.filterUpdated).items
		}
		return this.data.filterBy(this.filterUpdated).items
	},
	remove: function(c, j) {
		if (!Ext.isArray(c)) {
			c = [c]
		}
		j = j === true;
		var g = this,
			h = false,
			d = 0,
			a = c.length,
			b, f, e;
		for (; d < a; d++) {
			e = c[d];
			f = g.data.indexOf(e);
			if (g.allData) {
				g.allData.remove(e)
			}
			if (g.snapshot) {
				g.snapshot.remove(e)
			}
			if (f > -1) {
				b = e.phantom !== true;
				if (!j && b) {
					e.removedFrom = f;
					g.removed.push(e)
				}
				e.unjoin(g);
				g.data.remove(e);
				h = h || b;
				g.fireEvent("remove", g, e, f)
			}
		}
		g.fireEvent("datachanged", g);
		if (!j && g.autoSync && h && !g.autoSyncSuspended) {
			g.sync()
		}
	},
	filter: function(e, f) {
		if (Ext.isString(e)) {
			e = {
				property: e,
				value: f
			}
		}
		var d = this,
			a = d.decodeFilters(e),
			b = 0,
			g = d.sorters.length && d.sortOnFilter && !d.remoteSort,
			c = a.length;
		for (; b < c; b++) {
			d.filters.replace(a[b])
		}
		if (d.remoteFilter) {
			delete d.totalCount;
			if (d.buffered) {
				d.pageMap.clear();
				d.loadPage(1)
			} else {
				d.currentPage = 1;
				d.load()
			}
		} else {
			if (d.filters.getCount()) {
				d.snapshot = d.snapshot || d.allData.clone() || d.data.clone();
				if (d.allData) {
					d.data = d.allData;
					delete d.allData
				}
				d.data = d.data.filter(d.filters.items);
				d.applyPaging();
				if (g) {
					d.sort()
				} else {
					d.fireEvent("datachanged", d);
					d.fireEvent("refresh", d)
				}
			}
		}
	},
	clearFilter: function(a) {
		var b = this;
		b.filters.clear();
		if (b.remoteFilter) {
			if (a) {
				return
			}
			delete b.totalCount;
			if (b.buffered) {
				b.pageMap.clear();
				b.loadPage(1)
			} else {
				b.currentPage = 1;
				b.load()
			}
		} else {
			if (b.isFiltered()) {
				b.data = b.snapshot.clone();
				delete b.allData;
				delete b.snapshot;
				b.applyPaging();
				if (a !== true) {
					b.fireEvent("datachanged", b);
					b.fireEvent("refresh", b)
				}
			}
		}
	},
	isFiltered: function() {
		var a = this.snapshot;
		return !!a && a !== (this.allData || this.data)
	},
	filterBy: function(b, a) {
		var c = this;
		c.snapshot = c.snapshot || c.allData.clone() || c.data.clone();
		c.data = c.queryBy(b, a || c);
		c.applyPaging();
		c.fireEvent("datachanged", c);
		c.fireEvent("refresh", c)
	},
	queryBy: function(b, a) {
		var c = this,
			d = c.snapshot || c.allData || c.data;
		return d.filterBy(b, a || c)
	},
	collect: function(b, a, c) {
		var d = this,
			e = (c === true && (d.snapshot || d.allData)) ? (d.snapshot || d.allData) : d.data;
		return e.collect(b, "data", a)
	},
	getById: function(a) {
		return (this.snapshot || this.allData || this.data).findBy(function(b) {
			return b.getId() === a
		})
	},
	removeAll: function(a) {
		var b = this;
		b.clearData();
		if (b.snapshot) {
			b.snapshot.clear()
		}
		if (b.allData) {
			b.allData.clear()
		}
		if (b.pageMap) {
			b.pageMap.clear()
		}
		if (a !== true) {
			b.fireEvent("clear", b)
		}
	}
});
Ext.define("SO.ux.layout.ItemSelector", {
	extend: Ext.layout.component.field.Field,
	alias: ["layout.itemselectorfield"],
	type: "itemselectorfield",
	defaultHeight: 200,
	sizeBodyContents: function(b, a) {
		var c = this;
		if (!Ext.isNumber(a)) {
			a = c.defaultHeight
		}
		c.owner.innerCt.setSize(b, a)
	}
});
Ext.define("Common.model.SerialNumberModel", {
	extend: Ext.data.Model,
	fields: [{
		name: "serialNumber"
	}, {
		name: "unitStatusKey"
	}, {
		name: "location"
	}, {
		name: "dateTime"
	}]
});
